Skip to content
Snippets Groups Projects
Commit 20c49e80 authored by Thibault Delavallée's avatar Thibault Delavallée
Browse files

[FIX][IMP] mail: update all notification status before sending bus notifications

Otherwise status of notifications is not correctly updated when sending them
on the bus.

Task ID 2068986
parent aee7283d
No related branches found
No related tags found
No related merge requests found
......@@ -157,18 +157,20 @@ class MailMail(models.Model):
failed = self.env['mail.notification']
if failure_type:
failed = notifications.filtered(lambda notif: notif.res_partner_id not in success_pids)
(notifications - failed).sudo().write({
'notification_status': 'sent',
'failure_type': '',
'failure_reason': '',
})
if failed:
failed.sudo().write({
'notification_status': 'exception',
'failure_type': failure_type,
'failure_reason': failure_reason,
})
messages = notifications.mapped('mail_message_id').filtered(lambda m: m.is_thread_message())
# TDE TODO: could be great to notify message-based, not notifications-based, to lessen number of notifs
messages._notify_mail_failure_update() # notify user that we have a failure
(notifications - failed).sudo().write({
'notification_status': 'sent',
'failure_type': '',
'failure_reason': '',
})
if not failure_type or failure_type == 'RECIPIENT': # if we have another error, we want to keep the mail.
mail_to_delete_ids = [mail.id for mail in self if mail.auto_delete]
self.browse(mail_to_delete_ids).sudo().unlink()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment