diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-05-16 18:19:49 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-05-16 18:19:49 +0200 |
| commit | 7b9aa21576798d7f8ffe2b2f73e403e276c4b39a (patch) | |
| tree | 68d438edff5535b124bac4d6f4e308341eaee122 /addons/mail | |
| parent | 3b3f85670f40231768a409e3aebb636ad6871b56 (diff) | |
| parent | cecb1ec77d56fefdab53f3ef0bdda9a9c51c14be (diff) | |
[MERGE] forward port branch saas-15 up to cecb1ec77d5
Diffstat (limited to 'addons/mail')
| -rw-r--r-- | addons/mail/models/mail_mail.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/addons/mail/models/mail_mail.py b/addons/mail/models/mail_mail.py index 3027fc43edc..9fde6ebe773 100644 --- a/addons/mail/models/mail_mail.py +++ b/addons/mail/models/mail_mail.py @@ -153,6 +153,7 @@ class MailMail(models.Model): if notif_emails: notifications = self.env['mail.notification'].search([ ('mail_message_id', 'in', notif_emails.mapped('mail_message_id').ids), + ('res_partner_id', 'in', notif_emails.mapped('recipient_ids').ids), ('is_email', '=', True)]) if mail_sent: notifications.write({ @@ -320,6 +321,20 @@ class MailMail(models.Model): }) mail_sent = False + # Update notification in a transient exception state to avoid concurrent + # update in case an email bounces while sending all emails related to current + # mail record. + notifs = self.env['mail.notification'].search([ + ('is_email', '=', True), + ('mail_message_id', 'in', mail.mapped('mail_message_id').ids), + ('res_partner_id', 'in', mail.mapped('recipient_ids').ids), + ('email_status', 'not in', ('sent', 'canceled')) + ]) + if notifs: + notifs.sudo().write({ + 'email_status': 'exception', + }) + # build an RFC2822 email.message.Message object and send it without queuing res = None for email in email_list: |
