[FIX] website_forum: fix translation from faq

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) <jke@openerp.com>
This commit is contained in:
Jeremy Kersten
2019-05-02 12:46:13 +00:00
parent f0bc5e0b52
commit 9c1ad3604e
+2 -1
View File
@@ -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,