summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2016-01-12 13:54:35 +0100
committerNicolas Lempereur <nle@odoo.com>2016-01-12 15:14:07 +0100
commitb24d759036f7ebccd93df008fbfc2605efaeb574 (patch)
treed05a09610498c78c100b0f98efb3c95a1367510b
parentcb79297a41b7747a9318fd4794dce422ee931060 (diff)
[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
-rw-r--r--addons/web_editor/models/ir_translation.py6
1 files changed, 5 insertions, 1 deletions
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 '<span data-oe-model="%(model)s" data-oe-translation-id="%(id)s" data-oe-translation-state="%(state)s">%(value)s</span>' % 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: '<span data-oe-translation-id="%(id)s" data-oe-translation-state="%(state)s">%(value)s</span>' % data
+ return edit_translation_mapping
return super(ir_translation, self)._get_terms_mapping(field, records)