diff --git a/addons/google_calendar/models/google_sync.py b/addons/google_calendar/models/google_sync.py index 63ad22e689b..9480288c427 100644 --- a/addons/google_calendar/models/google_sync.py +++ b/addons/google_calendar/models/google_sync.py @@ -246,7 +246,8 @@ class GoogleSync(models.AbstractModel): with google_calendar_token(self.env.user.sudo()) as token: if token: try: - google_id = google_service.insert(values, token=token, timeout=timeout) + send_updates = self._context.get('send_updates', True) + google_id = google_service.with_context(send_updates=send_updates).insert(values, token=token, timeout=timeout) # Everything went smoothly self.with_context(dont_notify=True).write({ 'google_id': google_id, diff --git a/addons/google_calendar/models/res_users.py b/addons/google_calendar/models/res_users.py index b420dc05f6a..3c54b3f6a20 100644 --- a/addons/google_calendar/models/res_users.py +++ b/addons/google_calendar/models/res_users.py @@ -69,13 +69,14 @@ class User(models.Model): synced_events = self.env['calendar.event']._sync_google2odoo(events - recurrences, default_reminders=default_reminders) # Odoo -> Google + send_updates = not full_sync recurrences = self.env['calendar.recurrence']._get_records_to_sync(full_sync=full_sync) recurrences -= synced_recurrences - recurrences._sync_odoo2google(calendar_service) + recurrences.with_context(send_updates=send_updates)._sync_odoo2google(calendar_service) synced_events |= recurrences.calendar_event_ids - recurrences._get_outliers() synced_events |= synced_recurrences.calendar_event_ids - synced_recurrences._get_outliers() events = self.env['calendar.event']._get_records_to_sync(full_sync=full_sync) - (events - synced_events)._sync_odoo2google(calendar_service) + (events - synced_events).with_context(send_updates=send_updates)._sync_odoo2google(calendar_service) return bool(events | synced_events) or bool(recurrences | synced_recurrences) diff --git a/addons/google_calendar/utils/google_calendar.py b/addons/google_calendar/utils/google_calendar.py index 8e81fb532e0..ae761e19f3d 100644 --- a/addons/google_calendar/utils/google_calendar.py +++ b/addons/google_calendar/utils/google_calendar.py @@ -67,7 +67,8 @@ class GoogleCalendarService(): @requires_auth_token def insert(self, values, token=None, timeout=TIMEOUT): - url = "/calendar/v3/calendars/primary/events?sendUpdates=all" + send_updates = self._context.get('send_updates', True) + url = "/calendar/v3/calendars/primary/events?sendUpdates=%s" % ("all" if send_updates else "none") headers = {'Content-type': 'application/json', 'Authorization': 'Bearer %s' % token} if not values.get('id'): values['id'] = uuid4().hex