summaryrefslogtreecommitdiff
path: root/addons/crm
diff options
context:
space:
mode:
authorNasreddin (bon) <bon@odoo.com>2021-03-31 17:34:25 +0000
committerThibault Delavallée <tde@odoo.com>2021-05-03 08:31:41 +0000
commit6915d17f5f10737c03c820b69eded3a7c0151907 (patch)
tree95b12727ce9eff919a65845db937f2c54796dfc5 /addons/crm
parenteb332de42a36b7235d5578d39d345a5ff1df7759 (diff)
[FIX] crm: display right partner and action when converting lead
Issue - Create a partner with email 'aaa@test.com' - In CRM settings, activate 'Leads' feature - Go to CRM -> Leads and create a Lead: - Set email field to 'aaa@test.com' - Click on 'Convert to opportunity' Neither the action or partner_id field is set to the right value. Cause Due to missing 'lead_id' field in template, the partner_id field is not recomputed since action is not recomputed. Solution Add 'lead_id' field as invisible in form. opw-2439722 Task ID-2452777 COM PR odoo/odoo#68618
Diffstat (limited to 'addons/crm')
-rw-r--r--addons/crm/tests/test_crm_lead_convert.py23
-rw-r--r--addons/crm/wizard/crm_lead_to_opportunity.py2
-rw-r--r--addons/crm/wizard/crm_lead_to_opportunity_views.xml1
3 files changed, 25 insertions, 1 deletions
diff --git a/addons/crm/tests/test_crm_lead_convert.py b/addons/crm/tests/test_crm_lead_convert.py
index 63a81cc5de5..48502f57154 100644
--- a/addons/crm/tests/test_crm_lead_convert.py
+++ b/addons/crm/tests/test_crm_lead_convert.py
@@ -5,6 +5,29 @@ from odoo import SUPERUSER_ID
from odoo.addons.crm.tests import common as crm_common
from odoo.fields import Datetime
from odoo.tests.common import tagged, users
+from odoo.tests.common import Form
+
+@tagged('lead_manage')
+class TestLeadConvertForm(crm_common.TestLeadConvertCommon):
+
+ @users('user_sales_manager')
+ def test_form_action_default(self):
+ """ Test Lead._find_matching_partner() """
+ lead = self.env['crm.lead'].browse(self.lead_1.ids)
+ customer = self.env['res.partner'].create({
+ "name": "Amy Wong",
+ "email": '"Amy, PhD Student, Wong" Tiny <AMY.WONG@test.example.com>'
+ })
+
+ wizard = Form(self.env['crm.lead2opportunity.partner'].with_context({
+ 'active_model': 'crm.lead',
+ 'active_id': lead.id,
+ 'active_ids': lead.ids,
+ }))
+
+ self.assertEqual(wizard.name, 'convert')
+ self.assertEqual(wizard.action, 'exist')
+ self.assertEqual(wizard.partner_id, customer)
@tagged('lead_manage')
diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py
index 7f138f2a281..fbf44fe39e3 100644
--- a/addons/crm/wizard/crm_lead_to_opportunity.py
+++ b/addons/crm/wizard/crm_lead_to_opportunity.py
@@ -77,7 +77,7 @@ class Lead2OpportunityPartner(models.TransientModel):
convert.lead_id.partner_id.email if convert.lead_id.partner_id.email else convert.lead_id.email_from,
include_lost=True).ids
- @api.depends('action')
+ @api.depends('action', 'lead_id')
def _compute_partner_id(self):
for convert in self:
if convert.action == 'exist':
diff --git a/addons/crm/wizard/crm_lead_to_opportunity_views.xml b/addons/crm/wizard/crm_lead_to_opportunity_views.xml
index 4534e4352cd..2a379c19411 100644
--- a/addons/crm/wizard/crm_lead_to_opportunity_views.xml
+++ b/addons/crm/wizard/crm_lead_to_opportunity_views.xml
@@ -13,6 +13,7 @@
<field name="team_id" widget="selection"/>
</group>
<group string="Opportunities" attrs="{'invisible': [('name', '!=', 'merge')]}">
+ <field name="lead_id" invisible="1"/>
<field name="duplicated_lead_ids" nolabel="1">
<tree>
<field name="create_date" widget="date"/>