From a3d2336b17298c3fd0d00a3c53a96c9cb17e6c2a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Dufays Date: Wed, 3 Jan 2024 07:24:11 +0000 Subject: [PATCH] [FIX] calendar: fix duplicate feedback in the chatter activity done note How to reproduce: - install crm - open a lead - create an activity call or meeting (and schedule it in the calendar) - mark it as done with a feedback The activity log in the chatter contains the feedback twice and shouldn't. The problem was caused by the synchronization of the event description with the related activities. When marking an activity as done, the event description is updated with the feedback which in turn update the activity note with the feedback. When logging the activity done in the chatter, the note and the feedback are logged leading to a duplicate feedback. We solve this by first logging the activity done in the chatter before updating the event description. Task-3653088 closes odoo/odoo#158268 X-original-commit: 0156204e465bc7f86643152cfff4d1aa33fd6935 Signed-off-by: Thibault Delavallee (tde) --- addons/calendar/models/mail_activity.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/calendar/models/mail_activity.py b/addons/calendar/models/mail_activity.py index da30c6629d4..b8a71d4a29b 100644 --- a/addons/calendar/models/mail_activity.py +++ b/addons/calendar/models/mail_activity.py @@ -28,15 +28,21 @@ class MailActivity(models.Model): return action def _action_done(self, feedback=False, attachment_ids=False): + events = self.calendar_event_id + # To avoid the feedback to be included in the activity note (due to the synchronization in event.write + # that updates the related activity note each time the event description is updated), + # when the activity is written as a note in the chatter in _action_done (leading to duplicate feedback), + # we call super before updating the description. As self is deleted in super, we load the related events before. + messages, activities = super(MailActivity, self)._action_done(feedback=feedback, attachment_ids=attachment_ids) if feedback: - for event in self.calendar_event_id: + for event in events: description = event.description description = '%s
%s' % ( description if not tools.is_html_empty(description) else '', _('Feedback: %(feedback)s', feedback=tools.plaintext2html(feedback)) if feedback else '', ) event.write({'description': description}) - return super(MailActivity, self)._action_done(feedback=feedback, attachment_ids=attachment_ids) + return messages, activities def unlink_w_meeting(self): events = self.mapped('calendar_event_id')