From 83ad2867ee196f328ba885aa570611e4bf09d90f Mon Sep 17 00:00:00 2001 From: michel Date: Tue, 21 Nov 2017 17:02:04 +0100 Subject: [PATCH] / --- .../wizard/coworking_event_weekly.py | 24 ++++++++++--------- .../wizard/coworking_event_weekly_views.xml | 8 +++++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/coworking_event/wizard/coworking_event_weekly.py b/coworking_event/wizard/coworking_event_weekly.py index fa487cb..e13951f 100644 --- a/coworking_event/wizard/coworking_event_weekly.py +++ b/coworking_event/wizard/coworking_event_weekly.py @@ -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 + } diff --git a/coworking_event/wizard/coworking_event_weekly_views.xml b/coworking_event/wizard/coworking_event_weekly_views.xml index 1f436c4..2a9936d 100644 --- a/coworking_event/wizard/coworking_event_weekly_views.xml +++ b/coworking_event/wizard/coworking_event_weekly_views.xml @@ -27,6 +27,14 @@ + +