From b0491c44457eef3daacc906802340589cdd87d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 12 Feb 2019 14:55:55 +0000 Subject: [FIX] mass_mailing: correctly find partner email in mass mailing In mass mailing access to partners when performing a mass mailing has been done in batch to speedup computation [1]. Emails are put into a dictionary allowing to find back the email based on partner_id. However the matching between the partner and its emails is done using a shortcut using the current document ID as partner ID. It works when performing a mass mailing on partners but fails when performing a mass mailing on models having message_get_default_recipients not returning only emails. Currently in saas-14 main models return only emails (crm, event, mailing contacts) but other models may encounter issues (applicants, tickets). This commit fixes it by correctly matching partner id and its found email. Related to task ID 1924711 Linked to PR #32496 [1] See 65ed4553a50fdbefc986b7d21f87a81c42b743c7 --- addons/mass_mailing/wizard/mail_compose_message.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/mass_mailing/wizard/mail_compose_message.py') diff --git a/addons/mass_mailing/wizard/mail_compose_message.py b/addons/mass_mailing/wizard/mail_compose_message.py index 782d7641190..bfc81d74a84 100644 --- a/addons/mass_mailing/wizard/mail_compose_message.py +++ b/addons/mass_mailing/wizard/mail_compose_message.py @@ -64,7 +64,8 @@ class MailComposeMessage(models.TransientModel): if mail_values.get('email_to'): recips = tools.email_split(mail_values['email_to']) else: - recips = tools.email_split(partners_email.get(res_id)) + partner_id = (mail_values.get('recipient_ids') or [(False, '')])[0][1] + recips = tools.email_split(partners_email.get(partner_id)) mail_to = recips[0].lower() if recips else False if (opt_out_list and mail_to in opt_out_list) or (seen_list and mail_to in seen_list) \ or (not mail_to or not email_re.findall(mail_to)): -- cgit v1.2.3