[FIX] mail: avoid concurrent update of notifications

This revision is a backport of revision
56596e5240

As the bug mentioned in the above revision
occurs as well in Odoo 10.0 and 11.0.

opw-1984293

closes odoo/odoo#33382

Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
This commit is contained in:
Denis Ledoux
2019-05-15 09:16:23 +00:00
parent 928e91c624
commit 5d6656d739
+13
View File
@@ -267,6 +267,19 @@ 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),
('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: