summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2021-05-21 08:46:20 +0000
committerNicolas Lempereur <nle@odoo.com>2021-05-26 11:23:28 +0000
commit965c67cb16d2a4ac10d35a01da3af311867a47e6 (patch)
treef75693ce6312c733ee78bd2867d912348812178c /addons
parentd53d8bdf789e8f79ea4d531d944686abb59d6a26 (diff)
[FIX] mail,test_mass_mailing: unblacklist with mass mailing
The optimization 2ccf0bd0dc does not take into account that to "unblacklist" a user, you have the archive the mail.blacklist record so only mail.blacklist active records need to be taken into account. Added test without the fix fails with: AssertionError: False is not true : MailTrace: email test.record.02@test.example.com (recipient res.partner(), state: sent, record: mailing.test.blacklist(166,)): found 0 records (1 expected) opw-2536304 closes odoo/odoo#71239 X-original-commit: 8ffd82249728b79959cfa61490730991a2b339d6 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/mail/wizard/mail_compose_message.py2
-rw-r--r--addons/test_mass_mailing/tests/test_mailing.py9
2 files changed, 9 insertions, 2 deletions
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index 517a797fc80..3384b32f94e 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -282,7 +282,7 @@ class MailComposer(models.TransientModel):
blacklisted_rec_ids = set()
if mass_mail_mode and issubclass(type(self.env[self.model]), self.pool['mail.thread.blacklist']):
self.env['mail.blacklist'].flush(['email'])
- self._cr.execute("SELECT email FROM mail_blacklist")
+ self._cr.execute("SELECT email FROM mail_blacklist WHERE active=true")
blacklist = {x[0] for x in self._cr.fetchall()}
if blacklist:
targets = self.env[self.model].browse(res_ids).read(['email_normalized'])
diff --git a/addons/test_mass_mailing/tests/test_mailing.py b/addons/test_mass_mailing/tests/test_mailing.py
index c5a90927df5..4f6fa34f8ee 100644
--- a/addons/test_mass_mailing/tests/test_mailing.py
+++ b/addons/test_mass_mailing/tests/test_mailing.py
@@ -225,10 +225,17 @@ class TestMassMailing(TestMassMailCommon):
mailing = self.env['mailing.mailing'].browse(self.mailing_bl.ids)
recipients = self._create_mailing_test_records(count=5)
- # blacklist records 3 and 4
+ # blacklist records 2, 3, 4
+ self.env['mail.blacklist'].create({'email': recipients[2].email_normalized})
self.env['mail.blacklist'].create({'email': recipients[3].email_normalized})
self.env['mail.blacklist'].create({'email': recipients[4].email_normalized})
+ # unblacklist record 2
+ self.env['mail.blacklist'].action_remove_with_reason(
+ recipients[2].email_normalized, "human error"
+ )
+ self.env['mail.blacklist'].flush(['active'])
+
mailing.write({'mailing_domain': [('id', 'in', recipients.ids)]})
mailing.action_put_in_queue()
with self.mock_mail_gateway(mail_unlink_sent=False):