From e2f7a51ed5b332c5911fa7b0208a803e3f7f238d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Wed, 4 Sep 2024 12:05:22 +0200 Subject: [PATCH] [FIX] tracking_manager: Avoid sending tracking o2m emails if you are subscribed to notes Example use case: - Enable custom tracking in project.project - Activate the task_ids field as custom tracking - Create a project and assign it to a user (different from ours) and make it a note follower - Create a task in the project - The project message of the task tracking task will not be sent to the note followers TT50676 --- tracking_manager/models/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tracking_manager/models/models.py b/tracking_manager/models/models.py index 7aa27286f..002b2b364 100644 --- a/tracking_manager/models/models.py +++ b/tracking_manager/models/models.py @@ -97,12 +97,13 @@ class Base(models.AbstractModel): } for field_name, messages in messages_by_field.items() ] - # use sudo as user may not have access to mail.message - record.sudo().message_post_with_view( + # We do not use message_post_with_view() because emails would be sent + rendered_template = self.env["ir.qweb"]._render( "tracking_manager.track_o2m_m2m_template", - values={"lines": messages}, - subtype_id=self.env.ref("mail.mt_note").id, + {"lines": messages, "object": record}, + minimal_qcontext=True, ) + record._message_log(body=rendered_template) def _tm_prepare_o2m_tracking(self): fnames = self._tm_get_fields_to_track()