From e10ae3f0245fd919bebb1e0392e7e796018fc584 Mon Sep 17 00:00:00 2001 From: Yolann Sabaux Date: Mon, 10 Jan 2022 12:07:12 +0000 Subject: [PATCH] [FIX] google_calendar, microsoft_calendar: ignore no partner created Description of the issue/feature this PR addresses: in version 15, sometimes Google and Microsoft calendar synchronizations break with error: Create/update: a mandatory field is not set. Delete: another model requires the record being deleted. If possible, archive it instead. Model: Calendar Attendee Information (calendar.attendee), Field: Contact (partner_id) This is happening, because when Odoo is syncing an event, it will match attendee with res.partner, if no existing partner is found, a new one will be created unless: - the address matches an existing mail alias ([alias_name]@[mail.catchall.domain]) - the address is invalid (eg. in outlook the email address is sometimes in the form /o=ExchangeLabs/ou=.../cn=Recipients/cn=... In this case we should not try to add the attendee to the odoo event. Current behavior before PR: Error when syncing that the customer can only solve by removing the erroneous attendee or remove the event from their calendar. Desired behavior after PR is merged: if the partner cannot be created we ignore it. opw-2670002 opw-2683889 opw-2702661 opw-2704631 opw-2711907 opw-2720032 opw-2722028 closes #82109 fixes #78678 closes odoo/odoo#82667 X-original-commit: 1cd470c8922119d0da0b69ab7d4b4ff746533689 Signed-off-by: Nicolas Lempereur (nle) Signed-off-by: yosa-odoo Co-authored-by: andro19951 --- addons/google_calendar/models/calendar.py | 4 +++- addons/microsoft_calendar/models/calendar.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/google_calendar/models/calendar.py b/addons/google_calendar/models/calendar.py index ceb6eeea4ed..12cb2e476ba 100644 --- a/addons/google_calendar/models/calendar.py +++ b/addons/google_calendar/models/calendar.py @@ -142,8 +142,10 @@ class Meeting(models.Model): # Create new attendees if attendee[2].get('self'): partner = self.env.user.partner_id - else: + elif attendee[1]: partner = attendee[1] + else: + continue attendee_commands += [(0, 0, {'state': attendee[2].get('responseStatus'), 'partner_id': partner.id})] partner_commands += [(4, partner.id)] if attendee[2].get('displayName') and not partner.name: diff --git a/addons/microsoft_calendar/models/calendar.py b/addons/microsoft_calendar/models/calendar.py index de66f23fe95..d3eb78fbab7 100644 --- a/addons/microsoft_calendar/models/calendar.py +++ b/addons/microsoft_calendar/models/calendar.py @@ -174,7 +174,7 @@ class Meeting(models.Model): if email in attendees_by_emails: # Update existing attendees commands_attendee += [(1, attendees_by_emails[email].id, {'state': state})] - else: + elif attendee[1]: # Create new attendees partner = attendee[1] commands_attendee += [(0, 0, {'state': state, 'partner_id': partner.id})]