summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2018-12-07 13:54:37 +0000
committerNicolas Martinelli <nim@odoo.com>2018-12-10 13:21:21 +0000
commit8cd7de22046df2c2387e0e2b637a2a0fa1041e1e (patch)
tree176eda97c712f4d69cd777cbd5a60f8a3112d47f
parent9e71d228edb4a4405c6c17fbeabc8f7969c26dc5 (diff)
[IMP] mail: model description
Allow to specify the `model_description` when sending an email to take into account for cases where the same model is used for different business concepts. opw-1915230
-rw-r--r--addons/mail/wizard/mail_compose_message.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index 5422a115fdf..f92e23c6cc1 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -199,6 +199,13 @@ class MailComposer(models.TransientModel):
""" Process the wizard content and proceed with sending the related
email(s), rendering any template patterns on the fly if needed. """
notif_layout = self._context.get('custom_layout')
+ # Several custom layouts make use of the model description at rendering, e.g. in the
+ # 'View <document>' button. Some models are used for different business concepts, such as
+ # 'purchase.order' which is used for a RFQ and and PO. To avoid confusion, we must use a
+ # different wording depending on the state of the object.
+ # Therefore, we can set the description in the context from the beginning to avoid falling
+ # back on the regular display_name retrieved in '_notify_prepare_template_context'.
+ model_description = self._context.get('model_description')
for wizard in self:
# Duplicate attachments linked to the email.template.
# Indeed, basic mail.compose.message wizard duplicates attachments in mass
@@ -253,6 +260,7 @@ class MailComposer(models.TransientModel):
notif_layout=notif_layout,
add_sign=not bool(wizard.template_id),
mail_auto_delete=wizard.template_id.auto_delete if wizard.template_id else False,
+ model_description=model_description,
**mail_values)
if ActiveModel._name == 'mail.thread' and wizard.model:
post_params['model'] = wizard.model