[FIX] microsoft_calendar : Only sync-write on existing element

In case of m event being removed by a change in recurrence further change is then only applied on the existing events and not all past events

closes odoo/odoo#79889

X-original-commit: 067d911b9bb105d8d86dd6bcf85181dd3cbadd8f
Signed-off-by: Arnaud Joset <arj@odoo.com>
This commit is contained in:
Florian Damhaut
2021-11-17 09:11:55 +00:00
parent 404ec3d44d
commit fb6525f82d
@@ -217,7 +217,9 @@ class MicrosoftSync(models.AbstractModel):
normal_events += [recurrent_event.odoo_id(self.env)]
else:
value = self.env['calendar.event']._microsoft_to_odoo_values(recurrent_event, (), default_values)
self.env['calendar.event'].browse(recurrent_event.odoo_id(self.env)).with_context(no_mail_to_attendees=True, mail_create_nolog=True).write(dict(value, need_sync_m=False))
event = self.env['calendar.event'].browse(recurrent_event.odoo_id(self.env)).exists()
if event:
event.with_context(no_mail_to_attendees=True, mail_create_nolog=True).write(dict(value, need_sync_m=False))
if value.get('start') and value.get('stop'):
values[(self.id, value.get('start'), value.get('stop'))] = dict(value, need_sync_m=False)