From 0e6bb2cecf5fa4185211b1f6cbe68d78ec26855a Mon Sep 17 00:00:00 2001 From: "Anh Thao Pham (pta)" Date: Fri, 11 Sep 2020 12:48:28 +0000 Subject: [PATCH] [FIX] crm: fix res.partner creation from Leads - Go to CRM > Settings and activate Leads - Go to CRM > Leads and create 2 Leads with a different phone number - Select the 2 created Leads and in Action menu, select Send email - Make sure that "Lead/Opportunity: Mass Mail" is selected as template - Send it - Go to Contacts 2 Contacts have been created from the Leads, but both have the same phone number. The issue comes from the override `default_get` of `res.partner` in crm module. It is using `active_id` from context to fetch the Lead to populate Partner data. This cannot work when several Leads are selected as the same `active_id` is used for all of them. opw-2333819 closes odoo/odoo#57638 X-original-commit: a84dcfb9475051082c6103f81bfa231ea50ed157 Signed-off-by: Anh Thao PHAM --- addons/crm/models/res_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/models/res_partner.py b/addons/crm/models/res_partner.py index 7bd5781c12e..49ebc452775 100644 --- a/addons/crm/models/res_partner.py +++ b/addons/crm/models/res_partner.py @@ -18,7 +18,7 @@ class Partner(models.Model): def default_get(self, fields): rec = super(Partner, self).default_get(fields) active_model = self.env.context.get('active_model') - if active_model == 'crm.lead': + if active_model == 'crm.lead' and len(self.env.context.get('active_ids', [])) <= 1: lead = self.env[active_model].browse(self.env.context.get('active_id')).exists() if lead: rec.update(