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 #40023

X-original-commit: e183393
Signed-off-by: Jason Van Malder <jasonvanmalder@users.noreply.github.com>
  • Loading branch information...
jasonvanmalder authored and fw-bot committed Nov 8, 2019
1 parent f22e717 commit 7f33a3abebf8883703890352c2dcc5845e01a38d
Showing with 2 additions and 2 deletions.
  1. +2 −2 addons/crm/models/crm_lead.py
@@ -953,15 +953,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 7f33a3a

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