From c2f337779b0644cc45264db7889d74d8a64e23e0 Mon Sep 17 00:00:00 2001 From: amdi-odoo Date: Wed, 13 Sep 2023 13:02:53 +0200 Subject: [PATCH] [IMP] google_calendar: add google sync helper Add a helper method to know when the user calendar is fully synced to Google Calendar, meaning when API calls can correctly be performed. The user calendar is considered fully synced if the Google API is correctly configured in the settings (Client ID / Secret) and the user has synced its calendar with its Google Account. Task-3285601 Part-of: odoo/odoo#133921 --- addons/google_calendar/models/res_users.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/google_calendar/models/res_users.py b/addons/google_calendar/models/res_users.py index 69a4a3d316b..429bbcbb1ef 100644 --- a/addons/google_calendar/models/res_users.py +++ b/addons/google_calendar/models/res_users.py @@ -133,6 +133,12 @@ class User(models.Model): _logger.exception("[%s] Calendar Synchro - Exception : %s!", user, exception_to_unicode(e)) self.env.cr.rollback() + def is_google_calendar_synced(self): + """ True if Google Calendar settings are filled (Client ID / Secret) and user calendar is synced + meaning we can make API calls, false otherwise.""" + self.ensure_one() + return self.google_calendar_token and self._get_google_sync_status() == 'sync_active' + def stop_google_synchronization(self): self.ensure_one() self.google_synchronization_stopped = True