From 052bc3880534e45f168f396005e7cfc3edad0490 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 12 Jul 2017 11:33:52 +0200 Subject: [PATCH] [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 --- addons/google_calendar/models/google_calendar.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/google_calendar/models/google_calendar.py b/addons/google_calendar/models/google_calendar.py index 8a751c7a45b..b3f29b6d7eb 100644 --- a/addons/google_calendar/models/google_calendar.py +++ b/addons/google_calendar/models/google_calendar.py @@ -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})