[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.

opw-749752
opw-751294
opw-751348
This commit is contained in:
Martin Trigaux
2017-09-13 11:23:35 +02:00
parent a52369274a
commit 052bc38805
@@ -249,7 +249,8 @@ class GoogleCalendar(models.AbstractModel):
if not self.get_need_synchro_attendee():
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
@@ -610,7 +611,8 @@ class GoogleCalendar(models.AbstractModel):
('event_id.final_date', '>', fields.Datetime.to_string(self.get_minTime())),
])
for att in my_attendees:
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(other_google_id):
att.write({'google_internal_event_id': other_google_id})