From 27d439901cd4f342a55d7c6ebf99b9b01770880d Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 2 Dec 2015 10:45:17 +0100 Subject: [PATCH] [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 --- openerp/addons/base/ir/ir_translation.py | 4 ++-- openerp/models.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/ir/ir_translation.py b/openerp/addons/base/ir/ir_translation.py index bc84437fddb..da3a3556a5f 100644 --- a/openerp/addons/base/ir/ir_translation.py +++ b/openerp/addons/base/ir/ir_translation.py @@ -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', diff --git a/openerp/models.py b/openerp/models.py index 0ddeb9193ab..076368a6095 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -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