Skip to content
Snippets Groups Projects
Commit 45b5ff34 authored by pedrambiria's avatar pedrambiria
Browse files

[FIX] google_calendar: not sending emails to existing event attendees


Before this commit: syncing with google led to sending emails to
attendees of existing future events on Odoo.

Steps to reproduce the first issue:

	- Install 'google_calendar' module
	- Integrate with Google Calendar in setting
	- Add an event to the Odoo calendar for future date
	- Add one external attendee to the event
	- Sync with Google

	Invitation emails would be sent to the attendees of the events.

Solution

	It's possible to not send emails to the attendees in api calls. So
the solution is to not send emails to the attendees for the syncing
time.

opw-2819046

closes odoo/odoo#92953

Signed-off-by: default avatarYannick Tivisse (yti) <yti@odoo.com>
parent 513b2de6
Branches
Tags
No related merge requests found
......@@ -199,7 +199,8 @@ class GoogleSync(models.AbstractModel):
return
with google_calendar_token(self.env.user.sudo()) as token:
if token:
google_id = google_service.insert(values, token=token, timeout=timeout)
send_updates = self._context.get('send_updates', True)
google_id = google_service.with_context(send_updates=send_updates).insert(values, token=token, timeout=timeout)
self.write({
'google_id': google_id,
'need_sync': False,
......
......@@ -96,13 +96,14 @@ class User(models.Model):
synced_events = self.env['calendar.event']._sync_google2odoo(events - recurrences, default_reminders=default_reminders)
# Odoo -> Google
send_updates = not full_sync
recurrences = self.env['calendar.recurrence']._get_records_to_sync(full_sync=full_sync)
recurrences -= synced_recurrences
recurrences._sync_odoo2google(calendar_service)
recurrences.with_context(send_updates=send_updates)._sync_odoo2google(calendar_service)
synced_events |= recurrences.calendar_event_ids - recurrences._get_outliers()
synced_events |= synced_recurrences.calendar_event_ids - synced_recurrences._get_outliers()
events = self.env['calendar.event']._get_records_to_sync(full_sync=full_sync)
(events - synced_events)._sync_odoo2google(calendar_service)
(events - synced_events).with_context(send_updates=send_updates)._sync_odoo2google(calendar_service)
return bool(events | synced_events) or bool(recurrences | synced_recurrences)
......
......@@ -58,7 +58,8 @@ class GoogleCalendarService():
@requires_auth_token
def insert(self, values, token=None, timeout=TIMEOUT):
url = "/calendar/v3/calendars/primary/events?sendUpdates=all"
send_updates = self._context.get('send_updates', True)
url = "/calendar/v3/calendars/primary/events?sendUpdates=%s" % ("all" if send_updates else "none")
headers = {'Content-type': 'application/json', 'Authorization': 'Bearer %s' % token}
if not values.get('id'):
values['id'] = uuid4().hex
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment