forked from michel/Coworking
Duration fail
This commit is contained in:
parent
32687eafcd
commit
8f80bfed16
@ -17,7 +17,7 @@ class Event(models.Model):
|
||||
date_start = fields.Date(default=fields.Date.context_today, required=True)
|
||||
date_end = fields.Date(required=True)
|
||||
|
||||
duration = fields.Float()
|
||||
duration = fields.Float(compute='_compute_duration')
|
||||
|
||||
|
||||
@api.constrains('date_end')
|
||||
@ -26,9 +26,8 @@ class Event(models.Model):
|
||||
if self.date_start > self.date_end:
|
||||
raise ValidationError(_('Date most be supperior to to start date'))
|
||||
|
||||
#
|
||||
# @api.constrains('duration')
|
||||
# def _check_duration(self):
|
||||
# """Calcul du temps entre date_start et date_end ne heure"""
|
||||
# for event in self:
|
||||
# self.date_start.hour - self.date_end-hour:
|
||||
|
||||
@api.depends('date_start', 'date_end')
|
||||
def _compute_duration(self):
|
||||
for event in self:
|
||||
event.duration = event.date_end - event.date_start
|
||||
|
@ -14,7 +14,7 @@
|
||||
<!-- <field name="manager" /> -->
|
||||
<field name="date_start" />
|
||||
<field name="date_end" />
|
||||
<field name="duration" />
|
||||
<field name="duration" readonly="1" />
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
|
Loading…
Reference in New Issue
Block a user