[FIX] google_calendar: avoid cachemiss error when record has been deleted between write and patch
In some cases, the module can patch an event but if it is deleted, some write will fails.
This fix prevent the following traceback:
```py
Traceback (most recent call last):
File "/home/odoo/src/odoo/15.0/odoo/fields.py", line 1057, in __get__
value = env.cache.get(record, self)
File "/home/odoo/src/odoo/15.0/odoo/api.py", line 889, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'calendar.event(30350266,).attendee_ids'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/odoo/src/odoo/15.0/odoo/api.py", line 886, in get
return field_cache[record._ids[0]]
KeyError: 30350266
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/odoo/src/odoo/15.0/odoo/fields.py", line 1057, in __get__
value = env.cache.get(record, self)
File "/home/odoo/src/odoo/15.0/odoo/api.py", line 889, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'calendar.event(30350266,).show_as'
During handling of the above exception, another exception occurred:
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 234, in _google_patch
self.need_sync = False
File "/home/odoo/src/odoo/15.0/odoo/fields.py", line 1217, in __set__
records.write({self.name: write_value})
File "/home/odoo/src/odoo/15.0/addons/google_calendar/models/calendar.py", line 55, in write
res = super(Meeting, self.with_context(dont_notify=notify_context)).write(values)
File "/home/odoo/src/odoo/15.0/addons/calendar/models/calendar_event.py", line 491, in write
previous_attendees = self.attendee_ids
File "/home/odoo/src/odoo/15.0/odoo/fields.py", line 3389, in __get__
return super().__get__(records, owner)
File "/home/odoo/src/odoo/15.0/odoo/fields.py", line 2603, in __get__
return super().__get__(records, owner)
File "/home/odoo/src/odoo/15.0/odoo/fields.py", line 1083, in __get__
recs._fetch_field(self)
File "/home/odoo/src/odoo/15.0/odoo/models.py", line 3276, in _fetch_field
self._read(fnames)
File "/home/odoo/src/odoo/15.0/odoo/models.py", line 3346, in _read
self.check_access_rule('read')
File "/home/odoo/src/odoo/15.0/odoo/models.py", line 3553, in check_access_rule
invalid = self - self._filter_access_rules_python(operation)
File "/home/odoo/src/odoo/15.0/odoo/models.py", line 3608, in _filter_access_rules_python
return self.sudo().filtered_domain(dom or [])
File "/home/odoo/src/odoo/15.0/odoo/models.py", line 5511, in filtered_domain
data = rec.mapped(key)
File "/home/odoo/src/odoo/15.0/odoo/models.py", line 5436, in mapped
recs = recs._fields[name].mapped(recs)
File "/home/odoo/src/odoo/15.0/odoo/fields.py", line 1176, in mapped
self.__get__(first(remaining), type(remaining))
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(30350266,), User: XXX)
```
X-original-commit: 2f0c9ca75de616da61e327259d03a8831b8e159b
Part-of: odoo/odoo#83040
This commit is contained in:
@@ -237,7 +237,7 @@ class GoogleSync(models.AbstractModel):
|
||||
except HTTPError as e:
|
||||
if e.response.status_code in (400, 403):
|
||||
self._google_error_handling(e)
|
||||
self.need_sync = False
|
||||
self.exists().with_context(dont_notify=True).need_sync = False
|
||||
|
||||
@after_commit
|
||||
def _google_insert(self, google_service: GoogleCalendarService, values, timeout=TIMEOUT):
|
||||
@@ -255,7 +255,7 @@ class GoogleSync(models.AbstractModel):
|
||||
except HTTPError as e:
|
||||
if e.response.status_code in (400, 403):
|
||||
self._google_error_handling(e)
|
||||
self.need_sync = False
|
||||
self.with_context(dont_notify=True).need_sync = False
|
||||
|
||||
def _get_records_to_sync(self, full_sync=False):
|
||||
"""Return records that should be synced from Odoo to Google
|
||||
|
||||
Reference in New Issue
Block a user