summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSwapnesh Shah <swapneshshah111@gmail.com>2020-10-10 10:29:39 +0000
committerGitHub <noreply@github.com>2021-05-06 10:49:39 +0000
commitf24ecceae28237e920efb3dd59d5b8d76f550723 (patch)
tree0707531f579142e1c805425fd8bfc4f119313d3f
parent64afb484b9785a4d739fef1207405a502d668ab8 (diff)
[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#70466 X-original-commit: f29597fce37350f1c05d98341b959809bbb160b2 Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
-rw-r--r--addons/mrp/models/mrp_workcenter.py2
1 files changed, 1 insertions, 1 deletions
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