diff --git a/addons/mail/models/mail_render_mixin.py b/addons/mail/models/mail_render_mixin.py index d281d78e529..2132b06ba15 100644 --- a/addons/mail/models/mail_render_mixin.py +++ b/addons/mail/models/mail_render_mixin.py @@ -107,12 +107,11 @@ class MailRenderMixin(models.AbstractModel): def _update_field_translations(self, fname, translations, digest=None): res = super()._update_field_translations(fname, translations, digest) - # TBD the below check is only for model_term translations. - # Because for model translations, super().update_field_translations will call write to check if self._unrestricted_rendering: - # If the rendering is unrestricted (e.g. mail.template), - # check the user is part of the mail editor group to modify a template if the template is dynamic - self._check_access_right_dynamic_template() + for lang in translations: + # If the rendering is unrestricted (e.g. mail.template), + # check the user is part of the mail editor group to modify a template if the template is dynamic + self.with_context(lang=lang)._check_access_right_dynamic_template() return res # ------------------------------------------------------------ diff --git a/odoo/addons/base/i18n/base.pot b/odoo/addons/base/i18n/base.pot index c77bb02df1b..3eb54b095bc 100644 --- a/odoo/addons/base/i18n/base.pot +++ b/odoo/addons/base/i18n/base.pot @@ -7359,6 +7359,13 @@ msgstr "" msgid "Cannot aggregate field %r." msgstr "" +#. module: base +#. odoo-python +#: code:addons/models.py:0 +#, python-format +msgid "The following language is not activated: %(missing_names)s" +msgstr "" + #. module: base #. odoo-python #: code:addons/base/models/assetsbundle.py:0 diff --git a/odoo/models.py b/odoo/models.py index 7b119b6f996..009beb6c1bd 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -3041,6 +3041,14 @@ class BaseModel(metaclass=MetaModel): """ self.ensure_one() + installed_lang = set(code for code, _ in self.env['res.lang'].get_installed()) + missing_languages = set(translations) - installed_lang + if missing_languages: + raise UserError( + _("The following language is not activated: %(missing_names)s", + missing_names=', '.join(missing_languages)) + ) + field = self._fields[field_name] if not field.translate: