From 8d48efeece448b25afef6d5b16dbc243977110e3 Mon Sep 17 00:00:00 2001 From: "Arthur Detroux (ard)" Date: Wed, 9 Nov 2022 08:46:25 +0000 Subject: [PATCH] [FIX] web_editor: add snippet_lang as a template cache context key In commit [1] it was decided that the Snippet Menu would have its UI in the user's language, while the Snippets' Content would be in the language of the website they are currently editing. To do so, a new context key was added: Snippet Lang. Unfortunately, while Odoo handles the compilation according to a language, website_id and more, it does not do so according to the snippet lang. It would not be an issue if the Snippets were compiled only in edit mode, as a Website only has one default language. Unfortunately the Snippet Content is also rendered in translate mode (Since the SnippetMenu is one big XML template), therefore it can be rendered in different Snippet Lang (though it's useless). This commit fixes that by adding Snippet Lang as a cache key so that if the key is present, it will re-compile the template. Steps to reproduce: - Create a new language - Translate a snippet (e.g. search s_cover view and translate contact us) - Create a new website with 2 languages, the new language as default and english - Enter translate mode - Leave it - Enter edit mode via the "Edit master" button - Drop the translated snippet - It will not be translated because the Snippet Menu was rendered in English first. A commit introduced after this one will test these steps. [1]: https://github.com/odoo/odoo/commit/55a978aa86967581956f855a1c5db33b7425bd15 X-original-commit: 6eba6203e9f1b8a730ab53f80fea8e7b78818bc7 Part-of: odoo/odoo#108643 --- addons/web_editor/models/ir_qweb_fields.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/web_editor/models/ir_qweb_fields.py b/addons/web_editor/models/ir_qweb_fields.py index f99d924d755..e5262d966ac 100644 --- a/addons/web_editor/models/ir_qweb_fields.py +++ b/addons/web_editor/models/ir_qweb_fields.py @@ -134,6 +134,9 @@ class IrQWeb(models.AbstractModel): directives.insert(index, 'install') return directives + def _get_template_cache_keys(self): + return super()._get_template_cache_keys() + ['snippet_lang'] + #------------------------------------------------------ # QWeb fields