diff --git a/addons/mail/models/mail_mail.py b/addons/mail/models/mail_mail.py index d846041c9f54125f7937404085c87a0b1db645e1..029caf22b018942a9f05dba2d6bb387a5077dc55 100644 --- a/addons/mail/models/mail_mail.py +++ b/addons/mail/models/mail_mail.py @@ -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()