[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:
Thibault Delavallée
2024-04-16 07:02:57 +00:00
parent 1e45ec7b36
commit f21801ec93
2 changed files with 15 additions and 4 deletions
-1
View File
@@ -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:
+15 -3
View File
@@ -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)