summaryrefslogtreecommitdiff
path: root/addons/mail/models/mail_thread.py
diff options
context:
space:
mode:
authormreficent <miquel.raich@eficent.com>2020-03-23 16:02:13 +0000
committerThibault Delavallée <tde@odoo.com>2020-04-24 09:30:55 +0000
commitb1a5bf95f8ce26944959c97b760239d008efec95 (patch)
tree3dc79ef9aa0d66a00783e4f64163583254980752 /addons/mail/models/mail_thread.py
parent797403c0a9e6c7c0b23dbe04b050d59821b2953c (diff)
[IMP] mail: add a hook in _notify_record_by_email to add model-specific values
PURPOSE Be able to customize notification email values in a given model by overriding a simple method instead of having to hijack the email creation process. SPECIFICATIONS Add a hook in mail.thread that can be overridden in specific addons, either by model or globally by inheriting mail.thread. Include _notify_email_headers in it so that it is correctly embedded in model-specific values computation. This removes the need to replace _notify_record_by_email long method in a custom module. Closes odoo/odoo#48213 Closes odoo/odoo#50097 closes odoo/odoo#50129 X-original-commit: 1ba8712d7a797cf2e821ae881cb1f1c4ea2fc11d Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/mail/models/mail_thread.py')
-rw-r--r--addons/mail/models/mail_thread.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index 75ed62c8a8e..5e19ef8d75f 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -2270,9 +2270,7 @@ class MailThread(models.AbstractModel):
'references': message.parent_id.sudo().message_id if message.parent_id else False,
'subject': mail_subject,
}
- headers = self._notify_email_headers()
- if headers:
- base_mail_values['headers'] = headers
+ base_mail_values = self._notify_by_email_add_values(base_mail_values)
Mail = self.env['mail.mail'].sudo()
emails = self.env['mail.mail'].sudo()
@@ -2425,6 +2423,19 @@ class MailThread(models.AbstractModel):
'lang': lang,
}
+ def _notify_by_email_add_values(self, base_mail_values):
+ """ Add model-specific values to the dictionary used to create the
+ notification email. Its base behavior is to compute model-specific
+ headers.
+
+ :param dict base_mail_values: base mail.mail values, holding message
+ to notify (mail_message_id and its fields), server, references, subject.
+ """
+ headers = self._notify_email_headers()
+ if headers:
+ base_mail_values['headers'] = headers
+ return base_mail_values
+
def _notify_compute_recipients(self, message, msg_vals):
""" Compute recipients to notify based on subtype and followers. This
method returns data structured as expected for ``_notify_recipients``. """