From d855e3911fa40472f471439c5b3d78e3f7f493a8 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 26 Feb 2019 16:05:59 +0000 Subject: [PATCH] [FIX] orm: backport of 06d73eab62 to 11.0 [FIX] models: do not erase master version For a translated field with a callable method (e.g. xml_translate), when modifying the value of this field in another language than en_US, the master version was lost. Before this patch: >>> record.arch = "

Title

" >>> record.with_context(lang='fr_FR').arch = "

Titre

" >>> record.with_context(lang='fr_FR').arch "

Titre

" >>> record.arch "

Titre

" # lost English version After this patch: >>> record.arch = "

Title

" >>> record.with_context(lang='fr_FR').arch = "

Titre

" >>> record.with_context(lang='fr_FR').arch "

Title

" # write had no effect >>> record.arch "

Title

" When modifying a translated HTML field in English, a matching to detect the difference and avoid losing the translations is done. This is not supported for update in another language. The main reason is the difficulty to detect changes in the architecture. To update translations, the supported way is to go to the list of translations and update them there. Before this patch, the given value in another language was given to the SQL query and made an update in database: if single_lang or not (has_translation and field.translate is True) -> True or not (True and False) -> True If a field is callable, it should also be ignored, the same way than translate=True fields opw-1887162 closes odoo/odoo#31451 --- odoo/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/models.py b/odoo/models.py index bedf7fec10e..130a561445f 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -3186,7 +3186,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): if hasattr(field, 'selection') and val: self._check_selection_field_value(name, val) if field.column_type: - if single_lang or not (has_trans and field.translate is True): + if single_lang or not (has_trans and field.translate): # val is not a translation: update the table val = field.convert_to_column(val, self, vals) updates.append((name, field.column_format, val))