diff --git a/addons/mail/models/res_users.py b/addons/mail/models/res_users.py index f663a1c9f5e..4455cc70f63 100644 --- a/addons/mail/models/res_users.py +++ b/addons/mail/models/res_users.py @@ -80,8 +80,9 @@ GROUP BY channel_moderator.res_users_id""", [tuple(self.ids)]) raise exceptions.RedirectWarning(msg, action.id, _('Go to the configuration panel')) users = super(Users, self).create(vals_list) - # Auto-subscribe to channels - self.env['mail.channel'].search([('group_ids', 'in', users.groups_id.ids)])._subscribe_users() + # Auto-subscribe to channels unless skip explicitly requested + if not self.env.context.get('mail_channel_nosubscribe'): + self.env['mail.channel'].search([('group_ids', 'in', users.groups_id.ids)])._subscribe_users() return users def write(self, vals): diff --git a/addons/test_mail/tests/test_performance.py b/addons/test_mail/tests/test_performance.py index 37095b8e79c..6651549d9c0 100644 --- a/addons/test_mail/tests/test_performance.py +++ b/addons/test_mail/tests/test_performance.py @@ -18,6 +18,7 @@ class BaseMailPerformance(TransactionCaseWithUserDemo): 'mail_create_nolog': True, 'mail_create_nosubscribe': True, 'mail_notrack': True, + 'mail_channel_nosubscribe': True, } self.user_employee = self.env['res.users'].with_context(self._quick_create_ctx).create({ 'name': 'Ernest Employee',