Skip to content
Snippets Groups Projects
Commit f29597fc authored by Swapnesh Shah's avatar Swapnesh Shah Committed by GitHub
Browse files

[FIX] mrp: compute duration when needed


Before this commit there would be trackback (TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType') when you will try to remove field Start date as we are using the field to compute duration.

With this commit, we compute duration when Both fields are present.

closes odoo/odoo#59693

Signed-off-by: default avatarRémy Voet <ryv-odoo@users.noreply.github.com>
parent 8e4efd98
No related branches found
No related tags found
No related merge requests found
......@@ -270,7 +270,7 @@ class MrpWorkcenterProductivity(models.Model):
@api.depends('date_end', 'date_start')
def _compute_duration(self):
for blocktime in self:
if blocktime.date_end:
if blocktime.date_start and blocktime.date_end:
d1 = fields.Datetime.from_string(blocktime.date_start)
d2 = fields.Datetime.from_string(blocktime.date_end)
diff = d2 - d1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment