From 7e894aca0b3a0c79121214d059a850f4628d75bc Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 5 Jan 2018 16:02:22 +0100 Subject: [PATCH] [FIX] models: do not keep the old source in case of copy override Current behaviour when duplicating a record: apply copy override in the user language (e.g. "%s (copy)") copy the previous term in all the other languages (including) So if product was named: cheeses (en) kaas (nl) fromage (fr) Duplicating the product, while in French, will result into: cheeses (en) kaas (nl) fromage (copie) (fr) This is a problem if there is a unicity constrain on the field, it will be raised (there is already a product named 'cheese') After this PR: Duplicating the product, while in French, will result into: fromage (copie) (en) kaas (nl) fromage (copie) (fr) This applies **only** if there is an override of copy This is detected by comparing the old and new value for the user language Fixes #7010 Closes #22052 --- odoo/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/odoo/models.py b/odoo/models.py index e7be6c5b381..5d589551f08 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -3822,7 +3822,9 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): del vals['module'] # duplicated vals is not linked to any module vals['res_id'] = target_id if vals['lang'] == old.env.lang and field.translate is True: - vals['source'] = old_wo_lang[name] + # force a source if the new_val was not changed by copy override + if new_val == old[name]: + vals['source'] = old_wo_lang[name] # the value should be the new value (given by copy()) vals['value'] = new_val Translation.create(vals)