[FIX] crm: do not update assign date when converting a lead to opp
'date_open' is the date when a user is assigned to a lead / opportunity. It should not be set when converting a lead to an opportunity, as those two flows are different. Only setting a responsible should update it. Task-3515225 X-original-commit: a3dbe23b83e7aae108ff72737c69c783e059f603 Part-of: odoo/odoo#161918
This commit is contained in:
@@ -1708,7 +1708,6 @@ class Lead(models.Model):
|
||||
new_team_id = team_id if team_id else self.team_id.id
|
||||
upd_values = {
|
||||
'type': 'opportunity',
|
||||
'date_open': self.env.cr.now(),
|
||||
'date_conversion': self.env.cr.now(),
|
||||
}
|
||||
if customer != self.partner_id:
|
||||
|
||||
@@ -562,11 +562,23 @@ class TestCRMLead(TestCrmCommon):
|
||||
|
||||
@users('user_sales_manager')
|
||||
def test_crm_lead_stages(self):
|
||||
lead = self.lead_1.with_user(self.env.user)
|
||||
self.assertEqual(lead.team_id, self.sales_team_1)
|
||||
first_now = datetime(2023, 11, 6, 8, 0, 0)
|
||||
with patch.object(self.env.cr, 'now', lambda: first_now), \
|
||||
freeze_time(first_now):
|
||||
self.lead_1.write({'date_open': first_now})
|
||||
|
||||
lead.convert_opportunity(self.contact_1)
|
||||
lead = self.lead_1.with_user(self.env.user)
|
||||
self.assertEqual(lead.date_open, first_now)
|
||||
self.assertEqual(lead.team_id, self.sales_team_1)
|
||||
self.assertEqual(lead.user_id, self.user_sales_leads)
|
||||
|
||||
second_now = datetime(2023, 11, 8, 8, 0, 0)
|
||||
with patch.object(self.env.cr, 'now', lambda: second_now), \
|
||||
freeze_time(second_now):
|
||||
lead.convert_opportunity(self.contact_1)
|
||||
self.assertEqual(lead.date_open, first_now)
|
||||
self.assertEqual(lead.team_id, self.sales_team_1)
|
||||
self.assertEqual(lead.user_id, self.user_sales_leads)
|
||||
|
||||
lead.action_set_won()
|
||||
self.assertEqual(lead.probability, 100.0)
|
||||
|
||||
Reference in New Issue
Block a user