From 4c687fb6a53c54646f9cc96a5aad61cafd2c37ac Mon Sep 17 00:00:00 2001 From: michel Date: Fri, 10 Nov 2017 17:08:56 +0100 Subject: [PATCH] / --- models/event.py | 10 +++++++--- views/event_views.xml | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/models/event.py b/models/event.py index c00327c..9e0293c 100644 --- a/models/event.py +++ b/models/event.py @@ -14,8 +14,8 @@ class Event(models.Model): title = fields.Char(required=True) # manager = fields.Many2one('coworker.users', 'Manager', required=True, index=True) - date_start = fields.Date(default=fields.Date.context_today, required=True) - date_end = fields.Date(required=True) + date_start = fields.Datetime(default=fields.Date.context_today, required=True) + date_end = fields.Datetime(required=True) duration = fields.Float(compute='_compute_duration') @@ -30,4 +30,8 @@ class Event(models.Model): @api.depends('date_start', 'date_end') def _compute_duration(self): for event in self: - event.duration = event.date_end - event.date_start + if event.duration is True: + t1 = fields.Datetime.from_string(event.date_end) + t2 = fields.Datetime.from_string(event.date_start) + d1 = datetime.strptime(t1, fmt) + d2 = datetime.strptime(t2, fmt) diff --git a/views/event_views.xml b/views/event_views.xml index addc252..ad20cdf 100644 --- a/views/event_views.xml +++ b/views/event_views.xml @@ -14,7 +14,7 @@ - +