diff options
| author | Thibault Delavallée <tde@odoo.com> | 2018-04-27 17:21:18 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2018-08-07 15:43:06 +0200 |
| commit | 89051058f4ab7069024f7f6cf2caac05bd68b499 (patch) | |
| tree | 716f9a67e7c663f6ab2e28efa83ca82feff67f9f /addons/mail/wizard/mail_resend_message.py | |
| parent | df8130b2fa3a829f798e3aef648f75b5cd90f1f6 (diff) | |
[REF] mail: clean code related to notification email generation
This commit cleans code about sending email notification to recipients.
Purpose of this code is to prepare notification emails, group recipients
and finally send emails. In this commit we clean and optimize a bit by
* propagating some additional parameter to simplify code, like record
on which the notification process runs;
* inlining some code currently located in sub-methods. It eases code
understanding as there are less code jumps. As those methods are not
inherited inlining them can be done;
* simplifying a bit notification emails preparation and computation;
It allows to save a few query by avoiding to fetch and browse again some
data that were already computed.
This commit is linked to task ID 47934 and PR #24033. No functional change
should occur with this commit.
Diffstat (limited to 'addons/mail/wizard/mail_resend_message.py')
| -rw-r--r-- | addons/mail/wizard/mail_resend_message.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/addons/mail/wizard/mail_resend_message.py b/addons/mail/wizard/mail_resend_message.py index 38815c1a64d..bf56128ad61 100644 --- a/addons/mail/wizard/mail_resend_message.py +++ b/addons/mail/wizard/mail_resend_message.py @@ -57,7 +57,10 @@ class MailResendMessage(models.TransientModel): to_send = wizard.partner_ids.filtered(lambda p: p.resend).mapped("partner_id") notif_to_cancel = wizard.notification_ids.filtered(lambda notif: notif.res_partner_id in to_cancel and notif.email_status in ('exception', 'bounce')) notif_to_cancel.sudo().write({'email_status': 'canceled'}) - to_send.sudo()._notify(self.mail_message_id, force_send=True, send_after_commit=False) + if to_send: + message = wizard.mail_message_id + record = self.env[message.model].browse(message.res_id) if message.model and message.res_id else None + to_send.sudo()._notify(self.mail_message_id, record, force_send=True, send_after_commit=False) self.mail_message_id._notify_failure_update() return {'type': 'ir.actions.act_window_close'} |
