From 33965afa5ec61943ff90e8330dd023ac682de4bd Mon Sep 17 00:00:00 2001 From: std-odoo Date: Tue, 5 Apr 2022 09:51:38 +0000 Subject: [PATCH] [IMP] mail: do not remove cancelled email during the sending Purpose ======= It's not the role of the sending method to remove non outgoing emails. Task-2587345 Part-of: odoo/odoo#73271 --- addons/mail/models/mail_mail.py | 2 -- addons/test_mass_mailing/tests/test_performance.py | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/mail/models/mail_mail.py b/addons/mail/models/mail_mail.py index 01dc0adc9a1..13e99ecb503 100644 --- a/addons/mail/models/mail_mail.py +++ b/addons/mail/models/mail_mail.py @@ -376,8 +376,6 @@ class MailMail(models.Model): try: mail = self.browse(mail_id) if mail.state != 'outgoing': - if mail.state != 'exception' and mail.auto_delete: - mail.sudo().unlink() continue # remove attachments if user send the link with the access_token diff --git a/addons/test_mass_mailing/tests/test_performance.py b/addons/test_mass_mailing/tests/test_performance.py index 3e7d6735307..6001309dca4 100644 --- a/addons/test_mass_mailing/tests/test_performance.py +++ b/addons/test_mass_mailing/tests/test_performance.py @@ -92,3 +92,6 @@ class TestMassMailBlPerformance(TestMassMailPerformanceBase): self.assertEqual(mailing.sent, 50) self.assertEqual(mailing.delivered, 50) + + cancelled_mail_count = self.env['mail.mail'].sudo().search([('mailing_id', '=', mailing.id)]) + self.assertEqual(len(cancelled_mail_count), 12, 'Should not have auto deleted the blacklisted emails')