From 415d49f3f19dcad83bcb1e115d7d584e61bd93ac Mon Sep 17 00:00:00 2001 From: Arnaud Joset Date: Wed, 30 Jun 2021 09:30:46 +0000 Subject: [PATCH] [FIX] calendar: allow to copy event without messing with attendees Before this commit, when an event was duplicated, the attendee records were shared between copies. Accepting an event in one event would set the same answer on the other. After this commit, the attendee records are recreated based on the partner and attendee status are reset. Taskid: 2484335 Part-of: odoo/odoo#68700 --- addons/calendar/models/calendar_event.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/addons/calendar/models/calendar_event.py b/addons/calendar/models/calendar_event.py index 11ac5d772fa..a59235770b6 100644 --- a/addons/calendar/models/calendar_event.py +++ b/addons/calendar/models/calendar_event.py @@ -569,6 +569,20 @@ class Meeting(models.Model): self.env['calendar.alarm_manager']._notify_next_alarm(partner_ids) return result + def copy(self, default=None): + """When an event is copied, the attendees should be recreated to avoid sharing the same attendee records + between copies + """ + self.ensure_one() + if not default: + default = dict() + # We need to make sure that the attendee_ids are recreated with new ids to avoid sharing attendees between events + # The copy should not have the same attendee status than the original event + default.update({'partner_ids': [Command.set([])], 'attendee_ids': [Command.set([])]}) + copied_event = super().copy(default) + copied_event.write({'partner_ids': [(Command.set(self.partner_ids.ids))]}) + return copied_event + def _attendees_values(self, partner_commands): """ :param partner_commands: ORM commands for partner_id field (0 and 1 commands not supported)