[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#95781

X-original-commit: ac78ad6bf806ae3233ad38399771745edc8dc00d
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Arnaud Joset <arj@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
This commit is contained in:
pedrambiria
2022-07-12 07:31:41 +02:00
parent d3cc71db72
commit fb36e02de5
3 changed files with 7 additions and 4 deletions
+2 -1
View File
@@ -246,7 +246,8 @@ class GoogleSync(models.AbstractModel):
with google_calendar_token(self.env.user.sudo()) as token:
if token:
try:
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)
# Everything went smoothly
self.with_context(dont_notify=True).write({
'google_id': google_id,
+3 -2
View File
@@ -69,13 +69,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)
@@ -67,7 +67,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