From b24d759036f7ebccd93df008fbfc2605efaeb574 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 12 Jan 2016 13:54:35 +0100 Subject: [PATCH] [FIX] web_editor,base: transmit translation model There is a logic on the front-end to escape translated text content when saving them as ir.translation record. This logic was in part base on html elements and if these element were not coming from an html field other than "ir.ui.view" arch_db's field. This logic was introduced in 8.0, and something similar was later introduced in 9.0 with f5acea7, but in this instance, the information [data-oe-model] on nodes was not available. Thus some html field from other model than ui.ui.view would have their translation escaped erroneously. This commit adds a data-oe-model attribute on to-be-translated nodes which will then be available to the frontend. closes #10420 first-part-of: opw-659772 --- addons/web_editor/models/ir_translation.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/models/ir_translation.py b/addons/web_editor/models/ir_translation.py index d54591908bd..1dedb26d1bf 100644 --- a/addons/web_editor/models/ir_translation.py +++ b/addons/web_editor/models/ir_translation.py @@ -3,6 +3,10 @@ from openerp import models, api +def edit_translation_mapping(data): + data = dict(data, model=data['name'].partition(',')[0]) + return '%(value)s' % data + class ir_translation(models.Model): _inherit = 'ir.translation' @@ -10,5 +14,5 @@ class ir_translation(models.Model): def _get_terms_mapping(self, field, records): if self._context.get('edit_translations'): self.insert_missing(field, records) - return lambda data: '%(value)s' % data + return edit_translation_mapping return super(ir_translation, self)._get_terms_mapping(field, records)