Skip to content
Browse files

[FIX] crm: fix partner_id while converting a lead to an opportunity


    - Configure a mail server (incoming)
    - Enable leads in CRM app
    - Create a sales team with a mail alias (ex:
      and check "Pipeline" and "Leads"
    - Set a partner email with one of yours (ex: /!\
    - 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


    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.


closes #40001

Signed-off-by: Nicolas Martinelli (nim) <>
  • 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/
@@ -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[] =
if action == 'create':
partner = lead._create_lead_partner()
partner_id =
partner.team_id = lead.team_id
if partner_id:
lead.partner_id = partner_id
partner_ids[] = partner_id
return partner_ids

0 comments on commit e183393

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