From 0144dc9201a8a1e5bdd2992382ff2a3a52ed4717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 21 Nov 2022 11:57:49 +0000 Subject: [PATCH] [IMP] mail: give priority to asked options when rendering values When calling ``_render_fields`` asked options are now considered as more important compared to options defined in field itself (using render_options). Purpose is to allow to force some options when necessary. Task-2710804 (Mail: Clean MailThread API) Part-of: odoo/odoo#106072 --- addons/mail/models/mail_render_mixin.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/mail/models/mail_render_mixin.py b/addons/mail/models/mail_render_mixin.py index cfec4651007..63da0106246 100644 --- a/addons/mail/models/mail_render_mixin.py +++ b/addons/mail/models/mail_render_mixin.py @@ -583,9 +583,11 @@ class MailRenderMixin(models.AbstractModel): else: templates_res_ids = {self._context.get('lang'): (self, res_ids)} - # rendering options + # rendering options (update default defined on field by asked options) engine = getattr(self._fields[field], 'render_engine', engine) - options.update(**getattr(self._fields[field], 'render_options', {})) + field_options = getattr(self._fields[field], 'render_options', {}) + if options: + field_options.update(**options) return dict( (res_id, rendered) @@ -596,6 +598,6 @@ class MailRenderMixin(models.AbstractModel): tpl_res_ids, engine=engine, add_context=add_context, - options=options, + options=field_options, ).items() )