From 131239f7c400a56a42882809e831d3c8b45c046f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 27 Jul 2021 13:34:08 +0000 Subject: [PATCH] [FIX] portal: manually subscribe when inviting We should avoid autofollow as all recipeints are added as follower. When using templates this could lead to a lot of unwanted subscription especially in batch operation like share wizard. Better subscribe those new people manually. Task-2612911 PR odoo/odoo#60792 Signed-off-by: Thibault Delavallee (tde) --- addons/portal/wizard/portal_share.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/portal/wizard/portal_share.py b/addons/portal/wizard/portal_share.py index fed7e520067..c8c36418a01 100644 --- a/addons/portal/wizard/portal_share.py +++ b/addons/portal/wizard/portal_share.py @@ -59,7 +59,7 @@ class PortalShare(models.TransientModel): saved_lang = self.env.lang self = self.with_context(lang=partner.lang) template = self.env.ref('portal.portal_share_template', False) - active_record.with_context(mail_post_autofollow=self.env.context.get('mail_post_autofollow', True)).message_post_with_view(template, + active_record.message_post_with_view(template, values={'partner': partner, 'note': self.note, 'record': active_record, 'share_link': share_link}, subject=_("You are invited to access %s", active_record.display_name), @@ -75,7 +75,7 @@ class PortalShare(models.TransientModel): saved_lang = self.env.lang self = self.with_context(lang=partner.lang) template = self.env.ref('portal.portal_share_template', False) - active_record.with_context(mail_post_autofollow=self.env.context.get('mail_post_autofollow', True)).message_post_with_view(template, + active_record.message_post_with_view(template, values={'partner': partner, 'note': self.note, 'record': active_record, 'share_link': share_link}, subject=_("You are invited to access %s", active_record.display_name), @@ -83,4 +83,9 @@ class PortalShare(models.TransientModel): email_layout_xmlid='mail.mail_notification_light', partner_ids=[(6, 0, partner.ids)]) self = self.with_context(lang=saved_lang) + + # subscribe all recipients so that they receive future communication (better than + # using autofollow as more precise) + active_record.message_subscribe(partner_ids=self.partner_ids.ids) + return {'type': 'ir.actions.act_window_close'}