From 9c1ad3604e2cc508f9c8fbda9aaf77b9a8fcb82c Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Thu, 2 May 2019 12:41:56 +0000 Subject: [PATCH] [FIX] website_forum: fix translation from faq MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the refactoring of forum, faq sanitize is set to False. The editor of the faq can make what he want... But disable sanitize will break the translation since fields.py has code: ```python def _setup_attrs(self, model, name): super(Html, self)._setup_attrs(model, name) # Translated sanitized html fields must use html_translate or a callable. if self.translate is True and self.sanitize: self.translate = html_translate ``` Now we don't become html_translate magically, but we need to specify it in the field definition direclty. Courtesy of @mart-e This commit closes opw-1978662 closes odoo/odoo#33112 Signed-off-by: Jérémy Kersten (jke) --- addons/website_forum/models/forum.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index ee9098dd614..26cf278bb80 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -12,6 +12,7 @@ from werkzeug.exceptions import Forbidden from odoo import api, fields, models, tools, SUPERUSER_ID, _ from odoo.exceptions import UserError, ValidationError from odoo.tools import misc +from odoo.tools.translate import html_translate _logger = logging.getLogger(__name__) @@ -43,7 +44,7 @@ class Forum(models.Model): # description and use name = fields.Char('Forum Name', required=True, translate=True) active = fields.Boolean(default=True) - faq = fields.Html('Guidelines', default=_get_default_faq, translate=True, sanitize=False) + faq = fields.Html('Guidelines', default=_get_default_faq, translate=html_translate, sanitize=False) description = fields.Text( 'Description', translate=True,