[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 X-original-commit: 6915d17f5f10737c03c820b69eded3a7c0151907
This commit is contained in:
committed by
Thibault Delavallée
parent
094c94fcd3
commit
29398abb4e
@@ -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')
|
||||
|
||||
@@ -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':
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
Reference in New Issue
Block a user