diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/google_calendar/models/calendar_attendee.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/google_calendar/models/calendar_attendee.py')
| -rw-r--r-- | addons/google_calendar/models/calendar_attendee.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/addons/google_calendar/models/calendar_attendee.py b/addons/google_calendar/models/calendar_attendee.py new file mode 100644 index 00000000..3e3af0f5 --- /dev/null +++ b/addons/google_calendar/models/calendar_attendee.py @@ -0,0 +1,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 |
