From b6a580a25d1ebce4271c56fcd6d530ddf9aef438 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 26 Jun 2015 11:14:59 +0200 Subject: [PATCH] [FIX] google_calendar: wrong timezone When creating an event in at 4 pm, while being in UTC +2 (Europe/Brussels), The start date sent to Google was set as '2015-07-03T16:00:00+02:00', but the timezone was described as 'UTC', giving therefore giving contradictory information. At the end, in the google calendar, the event was set in the UTC timezone, while it should have been set in GMT +2 (Europe/Brussels). opw-640825 --- addons/google_calendar/google_calendar.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/google_calendar/google_calendar.py b/addons/google_calendar/google_calendar.py index a20143aff85..d55e31dafd6 100644 --- a/addons/google_calendar/google_calendar.py +++ b/addons/google_calendar/google_calendar.py @@ -202,6 +202,8 @@ class google_calendar(osv.AbstractModel): _name = 'google.%s' % STR_SERVICE def generate_data(self, cr, uid, event, isCreating=False, context=None): + if not context: + context = {} if event.allday: start_date = fields.datetime.context_timestamp(cr, uid, datetime.strptime(event.start, tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context).isoformat('T').split('T')[0] final_date = fields.datetime.context_timestamp(cr, uid, datetime.strptime(event.start, tools.DEFAULT_SERVER_DATETIME_FORMAT) + timedelta(hours=event.duration) + timedelta(days=isCreating and 1 or 0), context=context).isoformat('T').split('T')[0] @@ -226,19 +228,18 @@ class google_calendar(osv.AbstractModel): "method": "email" if alarm.type == "email" else "popup", "minutes": alarm.duration_minutes }) - data = { "summary": event.name or '', "description": event.description or '', "start": { type: start_date, vstype: None, - 'timeZone': 'UTC' + 'timeZone': context.get('tz', 'UTC'), }, "end": { type: final_date, vstype: None, - 'timeZone': 'UTC' + 'timeZone': context.get('tz', 'UTC'), }, "attendees": attendee_list, "reminders": { @@ -365,7 +366,7 @@ class google_calendar(osv.AbstractModel): url = "/calendar/v3/calendars/%s/events/%s?fields=%s&access_token=%s" % ('primary', google_event['id'], 'id,updated', self.get_token(cr, uid, context)) headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} - data = self.generate_data(cr, uid, oe_event, context) + data = self.generate_data(cr, uid, oe_event, context=context) data['sequence'] = google_event.get('sequence', 0) data_json = simplejson.dumps(data)