[FIX] google_calendar: backport 052bc38805 to 9.0

Backport following opw-1851612

[FIX] google_calendar: do not create an event with an invalid id

The id is useful to update existing events but sometimes we are getting some
ids that are not accepted by Google

Getting an error:
odoo.addons.google_account.models.google_service: Bad google request : {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid resource id value."
   }
  ],
  "code": 400,
  "message": "Invalid resource id value."
 }
}

Looks like existing events can have a _ in their id but new one, no longer.
It seems that these events are created by outlook calendar when synchronized
with Google Calendar.
This commit is contained in:
Martin Trigaux
2018-06-29 10:32:28 +02:00
parent 29c00a56da
commit 4ca9ee2548
+4 -2
View File
@@ -256,7 +256,8 @@ class google_calendar(osv.AbstractModel):
if not self.get_need_synchro_attendee(cr, uid, context=context):
data.pop("attendees")
if isCreating:
other_google_ids = [other_att.google_internal_event_id for other_att in event.attendee_ids if other_att.google_internal_event_id]
other_google_ids = [other_att.google_internal_event_id for other_att in event.attendee_ids
if other_att.google_internal_event_id and not other_att.google_internal_event_id.startswith('_')]
if other_google_ids:
data["id"] = other_google_ids[0]
return data
@@ -627,7 +628,8 @@ class google_calendar(osv.AbstractModel):
('event_id.final_date', '>', self.get_minTime(cr, uid, context=context).strftime(DEFAULT_SERVER_DATETIME_FORMAT)),
], context=context_norecurrent)
for att in att_obj.browse(cr, uid, my_att_ids, context=context):
other_google_ids = [other_att.google_internal_event_id for other_att in att.event_id.attendee_ids if other_att.google_internal_event_id and other_att.id != att.id]
other_google_ids = [other_att.google_internal_event_id for other_att in att.event_id.attendee_ids if
other_att.google_internal_event_id and other_att.id != att.id and not other_att.google_internal_event_id.startswith('_')]
for other_google_id in other_google_ids:
if self.get_one_event_synchro(cr, uid, other_google_id, context=context):
att_obj.write(cr, uid, [att.id], {'google_internal_event_id': other_google_id})