This commit is contained in:
michel 2017-11-10 17:08:56 +01:00
parent 8f80bfed16
commit 4c687fb6a5
2 changed files with 8 additions and 4 deletions

View File

@ -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)

View File

@ -14,7 +14,7 @@
<!-- <field name="manager" /> -->
<field name="date_start" />
<field name="date_end" />
<field name="duration" readonly="1" />
<field name="duration" />
</group>
</group>
</sheet>