From 5d650a71cb658a6b7ed42bb763a593544ac26dd6 Mon Sep 17 00:00:00 2001 From: michel Date: Fri, 10 Nov 2017 17:35:10 +0100 Subject: [PATCH] Yesssss --- models/event.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/models/event.py b/models/event.py index 0887f02..5e6b77c 100644 --- a/models/event.py +++ b/models/event.py @@ -30,8 +30,10 @@ class Event(models.Model): @api.depends('date_start', 'date_end') def _compute_duration(self): for event in self: - if event.duration is True: + if event.date_start and event.date_end: t1 = fields.Datetime.from_string(event.date_end) t2 = fields.Datetime.from_string(event.date_start) delta = t1 - t2 - hours = delta.days * 24.0 + round(float(delta.seconds) / 3600.0) + event.duration = delta.days * 24.0 + round(float(delta.seconds) / 3600.0) + else: + event.duration = 0.0