From 97afd18f1e863a4faed30aa3d722daf971c7a328 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 29 Dec 2023 14:21:01 +0100 Subject: [PATCH] [FIX] web_editor: prevent `en_US` key to be missing from arch_db Previous commit is fixing the code so that a view without `en_US` in arch_db jsonb value won't make the code crash (`get_related_views`). The commit before that actually improved the custom snippets so the translations are forwarded to it when it's saved. But that new code was introducing a way to have an arch without `en_US` value, which led to the bug described above. While the previous commit fixed the consequence of the issue, this commit solves the root cause of the issue, introduced 2 commits before. Arguably, this commit could be squashed in the one 2 commits ago, but it makes things more clear to figure. task-3375518 closes odoo/odoo#150945 X-original-commit: bf598d9098b4be36542a9a91c0dd1055cf36aed5 Signed-off-by: Romain Derie (rde) --- addons/web_editor/models/ir_ui_view.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/web_editor/models/ir_ui_view.py b/addons/web_editor/models/ir_ui_view.py index edeed41b4bd..824c1b819d2 100644 --- a/addons/web_editor/models/ir_ui_view.py +++ b/addons/web_editor/models/ir_ui_view.py @@ -150,6 +150,11 @@ class IrUiView(models.Model): existing_translation_dictionary.update(extra_translation_dictionary) translation_dictionary = existing_translation_dictionary + # The `en_US` jsonb value should always be set, even if english is not + # installed. If we don't do this, the custom snippet `arch_db` will only + # have a `fr_BE` key but no `en_US` key. + langs.add('en_US') + # 2. Set translations new_value = { lang: field_to.translate(lambda term: translation_dictionary.get(term, {}).get(lang), record_to[name_field_to])