Skip to content
Permalink
Browse files

[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 #40001

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
  • Loading branch information...
jasonvanmalder committed Nov 8, 2019
1 parent 0c3d925 commit e1833936255839cd34eba5758ca4c3124fd2522c
Showing with 2 additions and 2 deletions.
  1. +2 −2 addons/crm/models/crm_lead.py
@@ -859,15 +859,15 @@ def handle_partner_assignation(self, action='create', partner_id=False):
"""
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
if action == 'create':
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

0 comments on commit e183393

Please sign in to comment.
You can’t perform that action at this time.