Duration fail

This commit is contained in:
michel 2017-11-10 15:59:48 +01:00
parent 32687eafcd
commit 8f80bfed16
2 changed files with 7 additions and 8 deletions

View File

@ -17,7 +17,7 @@ class Event(models.Model):
date_start = fields.Date(default=fields.Date.context_today, required=True) date_start = fields.Date(default=fields.Date.context_today, required=True)
date_end = fields.Date(required=True) date_end = fields.Date(required=True)
duration = fields.Float() duration = fields.Float(compute='_compute_duration')
@api.constrains('date_end') @api.constrains('date_end')
@ -26,9 +26,8 @@ class Event(models.Model):
if self.date_start > self.date_end: if self.date_start > self.date_end:
raise ValidationError(_('Date most be supperior to to start date')) raise ValidationError(_('Date most be supperior to to start date'))
#
# @api.constrains('duration') @api.depends('date_start', 'date_end')
# def _check_duration(self): def _compute_duration(self):
# """Calcul du temps entre date_start et date_end ne heure""" for event in self:
# for event in self: event.duration = event.date_end - event.date_start
# self.date_start.hour - self.date_end-hour:

View File

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