From 457561aaa0fc6569a6c48d852b2b9bc0e5a1065f Mon Sep 17 00:00:00 2001 From: "Pedram (PEBR)" Date: Tue, 19 Dec 2023 17:15:24 +0100 Subject: [PATCH] [FIX] microsoft_calendar: ensure syncronization with cancelled event This commit addresses a synchronization issue with Microsoft Calendar, which arose after the implementation of commit d9c4043. The mentioned commit added tracking to the pre-commit process, inadvertently causing problems during calendar synchronization. The issue surfaced when the `_message_track_post_template` function was called in the pre-commit phase. If the appointment function was installed, the `_track_template` was overridden in this module, leading to an attempt to access the removed event, which raised an error and prevented calendar synchronization. With this modification, the `_track_template` will not be called for the created event that was cancelled in the same transaction. opw-3635261 closes odoo/odoo#148439 X-original-commit: f46276590f62bc578aab954a88e495519b46a07a Signed-off-by: Arnaud Joset (arj) --- addons/microsoft_calendar/models/calendar.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/microsoft_calendar/models/calendar.py b/addons/microsoft_calendar/models/calendar.py index 9c3d0edbc83..fea60a272c7 100644 --- a/addons/microsoft_calendar/models/calendar.py +++ b/addons/microsoft_calendar/models/calendar.py @@ -638,6 +638,9 @@ class Meeting(models.Model): """ user = self.env.user records = self.filtered(lambda e: not e.user_id or e.user_id == user or user.partner_id in e.partner_ids) + for event in records: + # remove the tracking data to avoid calling _track_template in the pre-commit phase + self.env.cr.precommit.data.pop(f'mail.tracking.create.{event._name}.{event.id}', None) super(Meeting, records)._cancel_microsoft() attendees = (self - records).attendee_ids.filtered(lambda a: a.partner_id == user.partner_id) attendees.do_decline()