[FIX] base: create translations of a duplicated record
When creating translations (click on blue flag) of a duplicated record, it used to have the module information of the duplicated record. It is also not useful to check the module when trying to find if a translation exists on this record as the res_id is present in the query. Fixes #9480
This commit is contained in:
parent
ae175d1574
commit
27d439901c
|
@ -440,12 +440,12 @@ class ir_translation(osv.osv):
|
||||||
# Check if record exists, else create it (at once)
|
# Check if record exists, else create it (at once)
|
||||||
sql = """INSERT INTO ir_translation (lang, src, name, type, res_id, value, module)
|
sql = """INSERT INTO ir_translation (lang, src, name, type, res_id, value, module)
|
||||||
SELECT %s, %s, %s, 'model', %s, %s, %s WHERE NOT EXISTS
|
SELECT %s, %s, %s, 'model', %s, %s, %s WHERE NOT EXISTS
|
||||||
(SELECT 1 FROM ir_translation WHERE lang=%s AND name=%s AND res_id=%s AND type='model' AND module=%s);
|
(SELECT 1 FROM ir_translation WHERE lang=%s AND name=%s AND res_id=%s AND type='model');
|
||||||
UPDATE ir_translation SET src = %s WHERE lang=%s AND name=%s AND res_id=%s AND type='model' AND module=%s;
|
UPDATE ir_translation SET src = %s WHERE lang=%s AND name=%s AND res_id=%s AND type='model' AND module=%s;
|
||||||
"""
|
"""
|
||||||
src = record[f['name']] or None
|
src = record[f['name']] or None
|
||||||
name = "%s,%s" % (f['model'], f['name'])
|
name = "%s,%s" % (f['model'], f['name'])
|
||||||
cr.execute(sql, (lg, src, name, f['id'], src, module, lg, name, f['id'], module, src, lg, name, id, module))
|
cr.execute(sql, (lg, src, name, f['id'], src, module, lg, name, f['id'], src, lg, name, id, module))
|
||||||
|
|
||||||
action = {
|
action = {
|
||||||
'name': 'Translate',
|
'name': 'Translate',
|
||||||
|
|
|
@ -4851,6 +4851,8 @@ class BaseModel(object):
|
||||||
del record['id']
|
del record['id']
|
||||||
# remove source to avoid triggering _set_src
|
# remove source to avoid triggering _set_src
|
||||||
del record['source']
|
del record['source']
|
||||||
|
# duplicated record is not linked to any module
|
||||||
|
del record['module']
|
||||||
record.update({'res_id': target_id})
|
record.update({'res_id': target_id})
|
||||||
if user_lang and user_lang == record['lang']:
|
if user_lang and user_lang == record['lang']:
|
||||||
# 'source' to force the call to _set_src
|
# 'source' to force the call to _set_src
|
||||||
|
|
Loading…
Reference in New Issue