[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:
Martin Trigaux 2015-12-02 10:45:17 +01:00
parent ae175d1574
commit 27d439901c
2 changed files with 4 additions and 2 deletions

View File

@ -440,12 +440,12 @@ class ir_translation(osv.osv):
# Check if record exists, else create it (at once)
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 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;
"""
src = record[f['name']] or None
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 = {
'name': 'Translate',

View File

@ -4851,6 +4851,8 @@ class BaseModel(object):
del record['id']
# remove source to avoid triggering _set_src
del record['source']
# duplicated record is not linked to any module
del record['module']
record.update({'res_id': target_id})
if user_lang and user_lang == record['lang']:
# 'source' to force the call to _set_src