diff options
| author | Denis Ledoux <dle@odoo.com> | 2015-06-26 11:14:59 +0200 |
|---|---|---|
| committer | Denis Ledoux <dle@odoo.com> | 2015-06-26 11:37:51 +0200 |
| commit | b6a580a25d1ebce4271c56fcd6d530ddf9aef438 (patch) | |
| tree | 56267623622ef4b216319ff85210ae27edbcf12d | |
| parent | 4213eebe2ebe6b0c81580176b263aeee9fa6a3fd (diff) | |
[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
| -rw-r--r-- | addons/google_calendar/google_calendar.py | 9 |
1 files 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) |
