From 57e5d703c2992c746e2a33e9a3e9e803e6789f32 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 2 Jun 2016 10:14:54 +0200 Subject: [PATCH] [FIX] mass_mailing: filter emails to avoid duplicates When subscribing a user to a mailing list, the `mail.mass_mailing.contact` created is processed to identify it's name and email from the address (method `get_name_email` called in `add_to_list` and `name_create`). For a better consistency, the search of existing contacts should also be done using the method `get_name_email`. This avoids that subscribing twice `Example ` fails to detect duplicates and creates two subscriptions. Closes #12265 --- addons/mass_mailing/controllers/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/mass_mailing/controllers/main.py b/addons/mass_mailing/controllers/main.py index 69317cb08c9..325ac1447d6 100644 --- a/addons/mass_mailing/controllers/main.py +++ b/addons/mass_mailing/controllers/main.py @@ -65,8 +65,12 @@ class MassMailController(http.Controller): def subscribe(self, list_id, email, **post): cr, uid, context = request.cr, request.uid, request.context Contacts = request.registry['mail.mass_mailing.contact'] + parsed_email = Contacts.get_name_email(email, context=context)[1] - contact_ids = Contacts.search_read(cr, SUPERUSER_ID, [('list_id', '=', int(list_id)), ('email', '=', email)], ['opt_out'], context=context) + contact_ids = Contacts.search_read( + cr, SUPERUSER_ID, + [('list_id', '=', int(list_id)), ('email', '=', parsed_email)], + ['opt_out'], context=context) if not contact_ids: Contacts.add_to_list(cr, SUPERUSER_ID, email, int(list_id), context=context) else: