/
This commit is contained in:
parent
00ecfada76
commit
83ad2867ee
@ -34,22 +34,20 @@ class CoworkingEventWeekly(models.TransientModel):
|
||||
# 5 - Rediriger vers la liste des événements (en automatique)
|
||||
# _LOGGER.warning()
|
||||
date_start_py = fields.Datetime.from_string(self.date_start_recurence)
|
||||
delta = timedelta(hours=self.duration)
|
||||
|
||||
duration_delta = timedelta(hours=self.duration)
|
||||
date_stop_py = fields.Datetime.from_string(self.date_stop_recurence)
|
||||
week_start = date_start_py.isocalendar()[1]
|
||||
week_stop = date_stop_py.isocalendar()[1]
|
||||
week_count = week_stop - week_start + 1
|
||||
delta = date_stop_py - date_start_py
|
||||
|
||||
wdelta = timedelta(days=7)
|
||||
|
||||
for week_number in xrange(week_count):
|
||||
for week_number in xrange(delta.days / 7 + 1):
|
||||
if week_number == 0:
|
||||
date_start = self.date_start_recurence
|
||||
date_stop = fields.Datetime.to_string(date_start_py + delta)
|
||||
date_stop = fields.Datetime.to_string(date_start_py + duration_delta)
|
||||
else:
|
||||
date_start = fields.Datetime.from_string(self.date_start_recurence) +\
|
||||
wdelta * week_number
|
||||
date_stop = fields.Datetime.to_string(date_start + delta)
|
||||
date_stop = fields.Datetime.to_string(date_start + duration_delta)
|
||||
date_start = fields.Datetime.to_string(date_start)
|
||||
self.env['coworking.event'].create({
|
||||
'title': self.title,
|
||||
@ -57,7 +55,11 @@ class CoworkingEventWeekly(models.TransientModel):
|
||||
'date_end': date_stop,
|
||||
'manager_id': self.manager_id.id
|
||||
})
|
||||
event_action = self.env.ref('coworking_event.event_action')
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'coworking.event',
|
||||
'view_mode': 'tree'}
|
||||
'type': event_action.type,
|
||||
'name': event_action.name,
|
||||
'res_model': event_action.res_model,
|
||||
'target': 'main',
|
||||
'view_mode': event_action.view_mode
|
||||
}
|
||||
|
@ -27,6 +27,14 @@
|
||||
</record>
|
||||
|
||||
<!-- Action -->
|
||||
<!-- <record id="weekly_event_action" model="ir.actions.act_window">
|
||||
<field name="name">Weekly event</field>
|
||||
<field name="res_model">coworking.event.weekly</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="coworking_event.view_form_weekly_event" />
|
||||
<field name="target">new</field>
|
||||
</record> -->
|
||||
|
||||
<act_window id="weekly_event_action" name="Weekly event"
|
||||
res_model="coworking.event.weekly" view_mode="form"
|
||||
target="new" />
|
||||
|
Loading…
Reference in New Issue
Block a user