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
19 lines
724 B
Python
19 lines
724 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
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'
|
|
|
|
@api.model
|
|
def _get_terms_mapping(self, field, records):
|
|
if self._context.get('edit_translations'):
|
|
self.insert_missing(field, records)
|
|
return edit_translation_mapping
|
|
return super(ir_translation, self)._get_terms_mapping(field, records)
|