From f7d1277080a91903342bbb4be44ce3a6ca814a38 Mon Sep 17 00:00:00 2001
From: "Nasreddin (bon)" <bon@odoo.com>
Date: Thu, 30 Apr 2020 07:41:30 +0000
Subject: [PATCH] [FIX] crm: Fix compute method on day open

Step to reproduce : Import from Excel a list of Opportunities.

The problem is that in _compute_day_open, the abs of the extraction
date_open - create_date is set as the lead's day_open.
As the date_open has no milliseconds, all those records which
create date is the same second have a date_open that is before their create_date.

Fixed it by comparing the date_create and date_open without microsecond.

Task ID 2222251

closes odoo/odoo#50574

X-original-commit: 51590b024f1a3d268aaeb06fb258d3fefa56a5c4
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
---
 addons/crm/models/crm_lead.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py
index f6fd9e83428a..f1baa578fc36 100644
--- a/addons/crm/models/crm_lead.py
+++ b/addons/crm/models/crm_lead.py
@@ -194,7 +194,7 @@ class Lead(models.Model):
         others = self - leads
         others.day_open = None
         for lead in leads:
-            date_create = fields.Datetime.from_string(lead.create_date)
+            date_create = fields.Datetime.from_string(lead.create_date).replace(microsecond=0)
             date_open = fields.Datetime.from_string(lead.date_open)
             lead.day_open = abs((date_open - date_create).days)
 
-- 
GitLab