[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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user