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 ' + }) + + 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 2a4eef8a447..72d0e236f64 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 23e2ef5d8f6..fa7a1215781 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 @@ +