From fe2be46214ce22f7c86e73984a4a0d8e443fbdf7 Mon Sep 17 00:00:00 2001 From: Arnaud Joset Date: Thu, 2 Jun 2022 08:37:08 +0000 Subject: [PATCH] [FIX] google_calendar: remove dead code The _sync_google_calendar method was copied in https://github.com/odoo/odoo/commit/24c2d7e9d609f02b1814be0faf82352bfeb45d96 in the google.calendar.credentials model from res.users but it was not useful or used. This method makes more sense on res.users model. closes odoo/odoo#92835 X-original-commit: f78431507ec9a5e2d9f1d2847d723e1f7bfeca11 Signed-off-by: Yannick Tivisse (yti) Signed-off-by: Arnaud Joset --- .../models/google_credentials.py | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/addons/google_calendar/models/google_credentials.py b/addons/google_calendar/models/google_credentials.py index 8c0e4cf9962..3e16d21ccb7 100644 --- a/addons/google_calendar/models/google_credentials.py +++ b/addons/google_calendar/models/google_credentials.py @@ -78,40 +78,3 @@ class GoogleCredentials(models.Model): "You should check your Client ID and secret on the Google APIs plateform or try to stop and restart your calendar synchronisation.", error_key) raise UserError(error_msg) - - def _sync_google_calendar(self, calendar_service: GoogleCalendarService): - self.ensure_one() - if self.synchronization_stopped: - return False - - # don't attempt to sync when another sync is already in progress, as we wouldn't be - # able to commit the transaction anyway (row is locked) - self.env.cr.execute("""SELECT id FROM res_users WHERE id = %s FOR NO KEY UPDATE SKIP LOCKED""", [self.id]) - if not self.env.cr.rowcount: - _logger.info("skipping calendar sync, locked user %s", self.login) - return False - - full_sync = not bool(self.calendar_sync_token) - with google_calendar_token(self) as token: - try: - events, next_sync_token, default_reminders = calendar_service.get_events(self.calendar_sync_token, token=token) - except InvalidSyncToken: - events, next_sync_token, default_reminders = calendar_service.get_events(token=token) - full_sync = True - self.calendar_sync_token = next_sync_token - - # Google -> Odoo - events.clear_type_ambiguity(self.env) - recurrences = events.filter(lambda e: e.is_recurrence()) - synced_recurrences = self.env['calendar.recurrence']._sync_google2odoo(recurrences) - synced_events = self.env['calendar.event']._sync_google2odoo(events - recurrences, default_reminders=default_reminders) - - # Odoo -> Google - recurrences = self.env['calendar.recurrence']._get_records_to_sync(full_sync=full_sync) - recurrences -= synced_recurrences - recurrences._sync_odoo2google(calendar_service) - synced_events |= recurrences.calendar_event_ids - recurrences._get_outliers() - events = self.env['calendar.event']._get_records_to_sync(full_sync=full_sync) - (events - synced_events)._sync_odoo2google(calendar_service) - - return bool(events | synced_events) or bool(recurrences | synced_recurrences)