From 58addb377e998f64d643c47c2925bff6dc71f05b Mon Sep 17 00:00:00 2001 From: Arnaud Joset Date: Fri, 14 Jan 2022 11:20:05 +0000 Subject: [PATCH] [FIX] google_calendar: improve error handling when the record does not exists anymore. Before this commit, the following traceback could be encountered when events were deleted: ```py Traceback (most recent call last): File "/home/odoo/src/odoo/15.0/addons/google_calendar/models/google_sync.py", line 43, in called_after func(self.with_env(env), *args, **kwargs) File "/home/odoo/src/odoo/15.0/addons/google_calendar/models/google_sync.py", line 233, in _google_patch self._google_error_handling(e) File "/home/odoo/src/odoo/15.0/addons/google_calendar/models/google_sync.py", line 177, in _google_error_handling start = self.start and self.start.strftime('%Y-%m-%d at %H:%M') or _("undefined time") File "/home/odoo/src/odoo/15.0/odoo/fields.py", line 1087, in __get__ raise MissingError("\n".join([ odoo.exceptions.MissingError: Record does not exist or has been deleted. (Record: calendar.event(28241777,), User: XXXX) ``` X-original-commit: e77cbc639032e7f58345942330102b37e7a55971 Part-of: odoo/odoo#83040 --- addons/google_calendar/models/google_sync.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/google_calendar/models/google_sync.py b/addons/google_calendar/models/google_sync.py index d304eb90f95..ce97457961c 100644 --- a/addons/google_calendar/models/google_sync.py +++ b/addons/google_calendar/models/google_sync.py @@ -173,6 +173,12 @@ class GoogleSync(models.AbstractModel): # We only handle the most problematic errors of sync events. if http_error.response.status_code in (403, 400): response = http_error.response.json() + if not self.exists(): + reason = "Google gave the following explanation: %s" % response['error'].get('message') + error_log = "Error while syncing record. It does not exists anymore in the database. %s" % reason + _logger.error(error_log) + return + if self._name == 'calendar.event': start = self.start and self.start.strftime('%Y-%m-%d at %H:%M') or _("undefined time") event_ids = self.id