blob: 3e3af0f5a36f1a3d870dbea6d0ab92b686de06ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
from odoo.addons.google_calendar.models.google_sync import google_calendar_token
from odoo.addons.google_calendar.utils.google_calendar import GoogleCalendarService
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
If not synced with Google, let Odoo in charge of sending emails
Otherwise, nothing to do: Google will send them
"""
with google_calendar_token(self.env.user.sudo()) as token:
if not token:
super()._send_mail_to_attendees(template_xmlid, force_send, ignore_recurrence)
def write(self, vals):
res = super().write(vals)
if vals.get('state'):
# When the state is changed, the corresponding event must be sync with google
google_service = GoogleCalendarService(self.env['google.service'])
self.event_id.filtered('google_id')._sync_odoo2google(google_service)
return res
|