[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
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user