[FIX] google_calendar: fix attendee deletion

When an attendee is deleted in google, we need to sync the odoo attendees and delete the ones that do not exist anymore in google.
Unfortunately, by doing so, we introduced an issue. We filtered attendees that were no longer existing when we looped on the attendee emails.

```py
odoo.exceptions.MissingError: Record does not exist or has been deleted.
(Record: calendar.attendee(YYY,), User: XXX)
```

This commit ensure that we filter only existing attendees.

X-original-commit: 0fb1002c9bb027d1694b834c52e4492a03c8a09d
Part-of: odoo/odoo#83040
This commit is contained in:
Arnaud Joset
2022-01-20 08:21:58 +00:00
parent 022d34e1e5
commit 8847d391e4
@@ -109,7 +109,7 @@ class RecurrenceRule(models.Model):
for odoo_attendee_email in set(existing_attendees.mapped('email')):
# Remove old attendees
if email_normalize(odoo_attendee_email) not in emails:
attendee = existing_attendees.filtered(lambda att: att.email == email_normalize(odoo_attendee_email))
attendee = existing_attendees.exists().filtered(lambda att: att.email == email_normalize(odoo_attendee_email))
self.calendar_event_ids.write({'need_sync': False, 'partner_ids': [(3, attendee.partner_id.id)]})
# Update the recurrence values