From 7105669b77a19bf5a80a6d481bca76139e0afafa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 29 Jan 2019 11:36:00 +0000 Subject: [PATCH] [FIX] website_slides: limit auto subscription In order to avoid spam and unwanted notification this commit limits auto subscription on channel when * creating a channel; * automatically telling a channel a new publication has been done; * creating a slide; As being a follower of a slide channel means following its slides user should choose manually to be follower of a channel, notably through the UI. A new way of managing subscription will come with elearning in mind and therefore auto subscription should be limited. Commit linked to task ID 1933820 and PR #30830. --- addons/website_slides/models/slide_channel.py | 4 ++++ addons/website_slides/models/slide_slide.py | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/website_slides/models/slide_channel.py b/addons/website_slides/models/slide_channel.py index fae545c87e9..f8cf257f7c4 100644 --- a/addons/website_slides/models/slide_channel.py +++ b/addons/website_slides/models/slide_channel.py @@ -145,6 +145,10 @@ class Channel(models.Model): if self.visibility == 'public': self.group_ids = False + @api.model + def create(self, vals): + return super(Channel, self.with_context(mail_create_nosubscribe=True)).create(vals) + @api.multi def write(self, vals): res = super(Channel, self).write(vals) diff --git a/addons/website_slides/models/slide_slide.py b/addons/website_slides/models/slide_slide.py index 2337e41aab4..02a9640cc2b 100644 --- a/addons/website_slides/models/slide_slide.py +++ b/addons/website_slides/models/slide_slide.py @@ -234,7 +234,6 @@ class Slide(models.Model): if not self.user_has_groups('website.group_website_publisher'): values['website_published'] = False slide = super(Slide, self).create(values) - slide.channel_id.message_subscribe(partner_ids=self.env.user.partner_id.ids) slide._post_publication() return slide @@ -325,7 +324,7 @@ class Slide(models.Model): publish_template = slide.channel_id.publish_template_id html_body = publish_template.with_context(base_url=base_url)._render_template(publish_template.body_html, 'slide.slide', slide.id) subject = publish_template._render_template(publish_template.subject, 'slide.slide', slide.id) - slide.channel_id.message_post( + slide.channel_id.with_context(mail_create_nosubscribe=True).message_post( subject=subject, body=html_body, subtype='website_slides.mt_channel_slide_published',