[FIX] crm: do not reset action name in convert wizard each time an option changes
Currently ``name`` field that holds the action type is recomputed each time duplicated leads are updated. However duplicated leads are often updated notably each time customer action (create / link / do nothing) and chosen customer are updated. As ``name`` compute method is mainly present to replace a default value its compute method is updated so that it nows compute only when not having a value. Once having a value user choice is kept. Task ID-2452777 COM PR odoo/odoo#68618 closes odoo/odoo#70254 X-original-commit: d75905f7acb1e7584d01792b4880fa76e6920d56 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -29,6 +29,32 @@ class TestLeadConvertForm(crm_common.TestLeadConvertCommon):
|
||||
self.assertEqual(wizard.action, 'exist')
|
||||
self.assertEqual(wizard.partner_id, customer)
|
||||
|
||||
@users('user_sales_manager')
|
||||
def test_form_name_onchange(self):
|
||||
""" Test Lead._find_matching_partner() """
|
||||
lead = self.env['crm.lead'].browse(self.lead_1.ids)
|
||||
lead_dup = lead.copy({'name': 'Duplicate'})
|
||||
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, 'merge')
|
||||
self.assertEqual(wizard.action, 'exist')
|
||||
self.assertEqual(wizard.partner_id, customer)
|
||||
self.assertEqual(wizard.duplicated_lead_ids[:], lead + lead_dup)
|
||||
|
||||
wizard.name = 'convert'
|
||||
wizard.action = 'create'
|
||||
self.assertEqual(wizard.action, 'create', 'Should keep user input')
|
||||
self.assertEqual(wizard.name, 'convert', 'Should keep user input')
|
||||
|
||||
|
||||
@tagged('lead_manage')
|
||||
class TestLeadConvert(crm_common.TestLeadConvertCommon):
|
||||
|
||||
@@ -50,7 +50,8 @@ class Lead2OpportunityPartner(models.TransientModel):
|
||||
@api.depends('duplicated_lead_ids')
|
||||
def _compute_name(self):
|
||||
for convert in self:
|
||||
convert.name = 'merge' if convert.duplicated_lead_ids and len(convert.duplicated_lead_ids) >= 2 else 'convert'
|
||||
if not convert.name:
|
||||
convert.name = 'merge' if convert.duplicated_lead_ids and len(convert.duplicated_lead_ids) >= 2 else 'convert'
|
||||
|
||||
@api.depends('lead_id')
|
||||
def _compute_action(self):
|
||||
|
||||
Reference in New Issue
Block a user