From 69fddf832f92637111ea7f0aef2c8dc9ac6dc848 Mon Sep 17 00:00:00 2001 From: Adrien Widart Date: Tue, 2 Feb 2021 08:14:12 +0000 Subject: [PATCH] [FIX] microsoft_calendar: add current partner to attendees When synced, if the user has an event on Microsoft Calendar and if this user is not the organizer (he is only an attendee), he will have to enable "Everybody's calendars" on Odoo Calendar to see this event. To reproduce the error: (Need one Google/Microsoft account A01 and one Microsoft account A02) 1. With A01, on Google/Microsoft calendar, create an event and invite A02 2. On Odoo, enable the sync with Microsoft - See [instructions](https://www.odoo.com/documentation/user/14.0/general/calendars/outlook/outlook_calendar.html) 3. Go to Odoo Calendar, click on "Sync With Outlook" - ! The sync must be done with A02 Error: The event is not displayed. The user must enable "Everybody's calendars" to see it. The problem comes from the attendees creation: it uses Microsoft attendees' email address to link a partner with the event. However, nothing ensures or requires that A02's email address is the same than current partner's one. As a result, it is possible that the current partner is not among the attendees. Moreover, Microsoft does not say which attendee is the synced one. Thus, this fix always adds the current partner to the attendees, so he will no longer need to enable "Everybody's calendars". OPW-2439189 closes odoo/odoo#66103 X-original-commit: 7579787c101923d450217cd167f50b9fcf21c690 Signed-off-by: Yannick Tivisse (yti) Signed-off-by: Adrien Widart --- addons/microsoft_calendar/models/calendar.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/microsoft_calendar/models/calendar.py b/addons/microsoft_calendar/models/calendar.py index f14d027d013..65af30e45ff 100644 --- a/addons/microsoft_calendar/models/calendar.py +++ b/addons/microsoft_calendar/models/calendar.py @@ -131,18 +131,15 @@ class Meeting(models.Model): commands_partner = [] microsoft_attendees = microsoft_event.attendees or [] - if microsoft_event.isOrganizer: - user = microsoft_event.owner(self.env) - microsoft_attendees += [{ - 'emailAddress': {'address': user.partner_id.email}, - 'status': {'response': 'organizer'} - }] emails = [a.get('emailAddress').get('address') for a in microsoft_attendees] existing_attendees = self.env['calendar.attendee'] if microsoft_event.exists(self.env): existing_attendees = self.env['calendar.attendee'].search([ ('event_id', '=', microsoft_event.odoo_id(self.env)), ('email', 'in', emails)]) + elif self.env.user.partner_id.email not in emails: + commands_attendee += [(0, 0, {'state': 'accepted', 'partner_id': self.env.user.partner_id.id})] + commands_partner += [(4, self.env.user.partner_id.id)] attendees_by_emails = {a.email: a for a in existing_attendees} for attendee in microsoft_attendees: email = attendee.get('emailAddress').get('address')