Skip to content
Permalink
Browse files

[FIX] mail: avoid concurrent update of notifications

This revision is a backport of revision
56596e5

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

opw-1984293

closes #33382

Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
  • Loading branch information...
beledouxdenis committed May 15, 2019
1 parent 928e91c commit 5d6656d739feff7abb8e191fdc038cc03b542d3b
Showing with 13 additions and 0 deletions.
  1. +13 −0 addons/mail/models/mail_mail.py
@@ -267,6 +267,19 @@ def send(self, auto_commit=False, raise_exception=False):
})
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:

0 comments on commit 5d6656d

Please sign in to comment.
You can’t perform that action at this time.