From bc4abcc1b31c5edf478dfd0c0b8c49626174cf7f Mon Sep 17 00:00:00 2001 From: Renaud Thiry Date: Mon, 20 Mar 2023 14:32:06 +0000 Subject: [PATCH] [FIX] mail: allow sending notification emails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add back the 'sudo()' on batch mail unlinking. Sudo is necessary to delete user notifications on auto-delete. Which makes sense as the recipient would have an email for it anyway. The sudo was there as far back as: c5c369355d095312d44a4793d6b77f7841577c12 Then transfered in this change: 036a739b62d05d437a277125e76c10e99c0f44e9 And removed in the recent optimization here: e38bfd25df1bb25e7e5695b536052d5a0c85c5c4 task-3225207 closes odoo/odoo#115956 X-original-commit: 93a28f17024511e30d3c70eb847c361ca87e0ffe Signed-off-by: Warnon Aurélien (awa) Signed-off-by: Thiry Renaud (reth) --- addons/mail/models/mail_mail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/models/mail_mail.py b/addons/mail/models/mail_mail.py index 5771cca328a..962a6cfa505 100644 --- a/addons/mail/models/mail_mail.py +++ b/addons/mail/models/mail_mail.py @@ -262,7 +262,7 @@ class MailMail(models.Model): # TDE TODO: could be great to notify message-based, not notifications-based, to lessen number of notifs messages._notify_message_notification_update() # notify user that we have a failure if not failure_type or failure_type in ['mail_email_invalid', 'mail_email_missing']: # if we have another error, we want to keep the mail. - self.filtered(lambda mail: mail.auto_delete).unlink() + self.sudo().filtered(lambda mail: mail.auto_delete).unlink() return True