summaryrefslogtreecommitdiff
path: root/addons/mass_mailing/models
diff options
context:
space:
mode:
authorDavid Beguin <dbe@odoo.com>2018-11-09 14:37:42 +0000
committerDavid Beguin <dbe@odoo.com>2018-11-20 11:37:05 +0000
commit1007df3dc3413b2b30af8a3feba023840f7566a3 (patch)
treea1eace90c6e65eebe1b4a4eef26ecb415a4a1ea4 /addons/mass_mailing/models
parente69b89b8fa8439fea27094ef86d97ffd8972124c (diff)
[IMP] mass_mailing : apply email_normalized on _get_opt_out_list
To avoid sending mail to an opted-out mass_mailing_contact with email address that is not strictly an email address (a <a@a.com> instead of a@a.com), the the get_opt_out method must be adapted to use the email_normalized field, as this method is only useful for that specific model. Task ID : 1896677
Diffstat (limited to 'addons/mass_mailing/models')
-rw-r--r--addons/mass_mailing/models/mass_mailing.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/addons/mass_mailing/models/mass_mailing.py b/addons/mass_mailing/models/mass_mailing.py
index ca6f39c07de..a4187e0ec6e 100644
--- a/addons/mass_mailing/models/mass_mailing.py
+++ b/addons/mass_mailing/models/mass_mailing.py
@@ -768,10 +768,9 @@ class MassMailing(models.Model):
# TODO DBE Fixme : Optimise the following to get real opt_out and opt_in
target_list_contacts = self.env['mail.mass_mailing.list_contact_rel'].search(
[('list_id', 'in', self.contact_list_ids.ids)])
- opt_out_contacts = target_list_contacts.filtered(lambda rel: rel.opt_out).mapped('contact_id.email')
- opt_in_contacts = target_list_contacts.filtered(lambda rel: not rel.opt_out).mapped('contact_id.email')
- normalized_email = [tools.email_split(c) for c in opt_out_contacts if c not in opt_in_contacts]
- opt_out = set(email[0].lower() for email in normalized_email if email)
+ opt_out_contacts = target_list_contacts.filtered(lambda rel: rel.opt_out).mapped('contact_id.email_normalized')
+ opt_in_contacts = target_list_contacts.filtered(lambda rel: not rel.opt_out).mapped('contact_id.email_normalized')
+ opt_out = set(c for c in opt_out_contacts if c not in opt_in_contacts)
_logger.info(
"Mass-mailing %s targets %s, blacklist: %s emails",