[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) <rde@odoo.com>
This commit is contained in:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user