[IMP] fields: translated html fields must use xml_translate or a callable

This commit is contained in:
Raphael Collet
2015-08-21 15:39:53 +02:00
parent def2527395
commit 75140d7ea1
+7 -1
View File
@@ -15,7 +15,7 @@ import xmlrpclib
from openerp.tools import float_round, frozendict, html_sanitize, ustr, OrderedSet
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as DATE_FORMAT
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT as DATETIME_FORMAT
from openerp.exceptions import UserError
from openerp.tools.translate import xml_translate
DATE_LENGTH = len(date.today().strftime(DATE_FORMAT))
DATETIME_LENGTH = len(datetime.now().strftime(DATETIME_FORMAT))
@@ -1227,6 +1227,12 @@ class Html(_String):
'strip_style': False, # whether to strip style attributes
}
def _setup_attrs(self, model, name):
super(Html, self)._setup_attrs(model, name)
# Translated html fields must use xml_translate or a callable.
if self.translate and not callable(self.translate):
self.translate = xml_translate
_column_sanitize = property(attrgetter('sanitize'))
_related_sanitize = property(attrgetter('sanitize'))
_description_sanitize = property(attrgetter('sanitize'))