[IMP] mail, test_mail: allow to bypass user / channel group-based subscription
A context key is added allowing to bypass user / channel synchronization when creating users. This is used notably in tests to avoid subscribing new test users to "general" channel created as default data. Purpose is to avoid interferences in query-based performance tests. It also avoids unnecessary data creation and/or update when it is not necessary especially in tests. LINKS Task ID-2070632 (main task) Task ID-2419762 (followup task) COM PR odoo/odoo#62859 ENT PR odoo/enterprise#15172 UPG PR odoo/upgrade#2005
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user