From 870a5d12e318cc0e541c95402cd0d34c5975cf52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 22 Mar 2023 12:58:42 +0000 Subject: [PATCH] [FIX] website_forum: correctly translate default welcome message Default value is currently not translated, which is sad. We therefore move it into its own default method, use translation marks, and Markupize the whole result. Task-3240082 (Forum: Reorganize and lint module) Part-of: odoo/odoo#114841 --- addons/website_forum/models/forum_forum.py | 47 ++++++++++++---------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/addons/website_forum/models/forum_forum.py b/addons/website_forum/models/forum_forum.py index 3a58afcc605..42c157e6258 100644 --- a/addons/website_forum/models/forum_forum.py +++ b/addons/website_forum/models/forum_forum.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models +from odoo import _, api, fields, models from odoo.tools.translate import html_translate from odoo.addons.http_routing.models.ir_http import slug @@ -18,6 +18,27 @@ class Forum(models.Model): ] _order = "sequence" + def _get_default_welcome_message(self): + return """ +
+
+
+
+

Welcome!

+

%(message_intro)s
%(message_post)s

+
+ +
+
+
""" % { + 'message_intro': _("This community is for professionals and enthusiasts of our products and services."), + 'message_post': _("Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together."), + 'hide_text': _('Hide Intro'), + 'register_text': _('Register')} + # description and use name = fields.Char('Forum Name', required=True, translate=True) sequence = fields.Integer('Sequence', default=1) @@ -41,27 +62,9 @@ class Forum(models.Model): description = fields.Text('Description', translate=True) teaser = fields.Text('Teaser', compute='_compute_teaser', store=True) welcome_message = fields.Html( - 'Welcome Message', - translate=True, - default="""
-
-
-
-

Welcome!

-

- This community is for professionals and enthusiasts of our products and services. -
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together. -

-
- -
-
-
""", - sanitize_attributes=False, - sanitize_form=False) + 'Welcome Message', translate=html_translate, + default=_get_default_welcome_message, + sanitize_attributes=False, sanitize_form=False) default_order = fields.Selection([ ('create_date desc', 'Newest'), ('write_date desc', 'Last Updated'),