summaryrefslogtreecommitdiff
path: root/addons/microsoft_calendar
diff options
context:
space:
mode:
authorAdrien Widart <awt@odoo.com>2020-11-26 09:49:12 +0000
committerAdrien Widart <awt@odoo.com>2020-11-26 10:16:59 +0000
commit694452e5581aa28ae89024a6b5f70a273fb2bdf8 (patch)
tree33440096b6854885881f202c0053405f4d52ecdb /addons/microsoft_calendar
parentc6c4b9f0e4bae03b51d232ea920de9587d8e2b73 (diff)
[FIX] microsoft_calendar: disable Odoo emails
When synced with Outlook, if a user adds an event to the Odoo Calendar, both Outlook and Odoo will send an invitation to attendees. To reproduce the error: (Need calendar) 1. Set up a mail catcher 2. Clean the calendar 3. Sync with Outlook - [Steps](https://www.odoo.com/documentation/user/14.0/general/calendars/outlook/outlook_calendar.html) 4. In Calendar, create a new event - Add some attendees 5. Save => The attendees will receive two invitations: one from Odoo and a second from Outlook. When synced, Odoo should not manage the emails sending. OPW-2387296 closes odoo/odoo#62383 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/microsoft_calendar')
-rw-r--r--addons/microsoft_calendar/models/__init__.py1
-rw-r--r--addons/microsoft_calendar/models/calendar_attendee.py20
2 files changed, 21 insertions, 0 deletions
diff --git a/addons/microsoft_calendar/models/__init__.py b/addons/microsoft_calendar/models/__init__.py
index 8d933a1a60b..a87bf35b73d 100644
--- a/addons/microsoft_calendar/models/__init__.py
+++ b/addons/microsoft_calendar/models/__init__.py
@@ -6,3 +6,4 @@ from . import microsoft_sync
from . import calendar
from . import calendar_recurrence_rule
from . import res_users
+from . import calendar_attendee
diff --git a/addons/microsoft_calendar/models/calendar_attendee.py b/addons/microsoft_calendar/models/calendar_attendee.py
new file mode 100644
index 00000000000..9a462c38f70
--- /dev/null
+++ b/addons/microsoft_calendar/models/calendar_attendee.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import models
+
+from odoo.addons.microsoft_calendar.models.microsoft_sync import microsoft_calendar_token
+
+
+class Attendee(models.Model):
+ _name = 'calendar.attendee'
+ _inherit = 'calendar.attendee'
+
+ def _send_mail_to_attendees(self, template_xmlid, force_send=False, ignore_recurrence=False):
+ """ Override the super method
+ If not synced with Microsoft Outlook, let Odoo in charge of sending emails
+ Otherwise, Microsoft Outlook will send them
+ """
+ with microsoft_calendar_token(self.env.user.sudo()) as token:
+ if not token:
+ super()._send_mail_to_attendees(template_xmlid, force_send, ignore_recurrence)