forked from michel/Coworking
/
This commit is contained in:
parent
8f80bfed16
commit
4c687fb6a5
@ -14,8 +14,8 @@ class Event(models.Model):
|
|||||||
title = fields.Char(required=True)
|
title = fields.Char(required=True)
|
||||||
# manager = fields.Many2one('coworker.users', 'Manager', required=True, index=True)
|
# manager = fields.Many2one('coworker.users', 'Manager', required=True, index=True)
|
||||||
|
|
||||||
date_start = fields.Date(default=fields.Date.context_today, required=True)
|
date_start = fields.Datetime(default=fields.Date.context_today, required=True)
|
||||||
date_end = fields.Date(required=True)
|
date_end = fields.Datetime(required=True)
|
||||||
|
|
||||||
duration = fields.Float(compute='_compute_duration')
|
duration = fields.Float(compute='_compute_duration')
|
||||||
|
|
||||||
@ -30,4 +30,8 @@ class Event(models.Model):
|
|||||||
@api.depends('date_start', 'date_end')
|
@api.depends('date_start', 'date_end')
|
||||||
def _compute_duration(self):
|
def _compute_duration(self):
|
||||||
for event in 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)
|
||||||
|
@ -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" readonly="1" />
|
<field name="duration" />
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
|
Loading…
Reference in New Issue
Block a user