[FIX] crm: make sure there is a create date when computing date_open
Display the field date_open in the crm.lead form view Create a new record Before this commit, there was a crash because since the record is a virtual one there is no create_date, hence the crash After this commit, we make sure we select records that have a create_date, and there is no crash OPW 1877080 closes #26499
This commit is contained in:
@@ -166,7 +166,7 @@ class Lead(models.Model):
|
||||
@api.depends('date_open')
|
||||
def _compute_day_open(self):
|
||||
""" Compute difference between create date and open date """
|
||||
for lead in self.filtered(lambda l: l.date_open):
|
||||
for lead in self.filtered(lambda l: l.date_open and l.create_date):
|
||||
date_create = fields.Datetime.from_string(lead.create_date)
|
||||
date_open = fields.Datetime.from_string(lead.date_open)
|
||||
lead.day_open = abs((date_open - date_create).days)
|
||||
@@ -174,7 +174,7 @@ class Lead(models.Model):
|
||||
@api.depends('date_closed')
|
||||
def _compute_day_close(self):
|
||||
""" Compute difference between current date and log date """
|
||||
for lead in self.filtered(lambda l: l.date_closed):
|
||||
for lead in self.filtered(lambda l: l.date_closed and l.create_date):
|
||||
date_create = fields.Datetime.from_string(lead.create_date)
|
||||
date_close = fields.Datetime.from_string(lead.date_closed)
|
||||
lead.day_close = abs((date_close - date_create).days)
|
||||
|
||||
Reference in New Issue
Block a user