[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
This commit is contained in:
std-odoo
2022-05-31 14:58:52 +02:00
parent 0ee53dc7bd
commit 33965afa5e
2 changed files with 3 additions and 2 deletions
-2
View File
@@ -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
@@ -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')