From f24ecceae28237e920efb3dd59d5b8d76f550723 Mon Sep 17 00:00:00 2001 From: Swapnesh Shah Date: Sat, 10 Oct 2020 10:29:39 +0000 Subject: [FIX] mrp: compute duration when needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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#70466 X-original-commit: f29597fce37350f1c05d98341b959809bbb160b2 Signed-off-by: Rémy Voet --- addons/mrp/models/mrp_workcenter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons') diff --git a/addons/mrp/models/mrp_workcenter.py b/addons/mrp/models/mrp_workcenter.py index 969461a4d61..1062b1dac03 100644 --- a/addons/mrp/models/mrp_workcenter.py +++ b/addons/mrp/models/mrp_workcenter.py @@ -328,7 +328,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 -- cgit v1.2.3