[FIX] crm: fix partner_id while converting a lead to an opportunity
Prerequisites
- Configure a mail server (incoming)
- Enable leads in CRM app
- Create a sales team with a mail alias (ex: testcrm@odoo.com)
and check "Pipeline" and "Leads"
- Set a partner email with one of yours (ex: bob@odoo.com) /!\
- Send a mail from bob to testcrm
- In the incoming mail server click on "Fetch"
Reproduce the issue:
- Convert the generated lead to an opportunity
- Choose "Existing customer" and set another one than the actual
- The opportunity is created but the customer is the old one
Cause:
The given partner_id is overriden by the old one in the
`handle_partner_assignation` method.
This commit gives the priority to the new partner_id.
OPW-2089404
closes odoo/odoo#40031
X-original-commit: e1833936255839cd34eba5758ca4c3124fd2522c
Signed-off-by: Jason Van Malder <jasonvanmalder@users.noreply.github.com>
This commit is contained in:
@@ -950,6 +950,8 @@ class Lead(models.Model):
|
||||
"""
|
||||
partner_ids = {}
|
||||
for lead in self:
|
||||
if partner_id:
|
||||
lead.partner_id = partner_id
|
||||
if lead.partner_id:
|
||||
partner_ids[lead.id] = lead.partner_id.id
|
||||
continue
|
||||
@@ -957,8 +959,6 @@ class Lead(models.Model):
|
||||
partner = lead._create_lead_partner()
|
||||
partner_id = partner.id
|
||||
partner.team_id = lead.team_id
|
||||
if partner_id:
|
||||
lead.partner_id = partner_id
|
||||
partner_ids[lead.id] = partner_id
|
||||
return partner_ids
|
||||
|
||||
|
||||
Reference in New Issue
Block a user