mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-21 20:12:07 +02:00
Initial commit: Core packages
This commit is contained in:
commit
12c29a983b
9512 changed files with 8379910 additions and 0 deletions
23
odoo-bringout-oca-ocb-mail/mail/models/res_groups.py
Normal file
23
odoo-bringout-oca-ocb-mail/mail/models/res_groups.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class ResGroups(models.Model):
|
||||
""" Update of res.groups class
|
||||
- if adding users from a group, check mail.channels linked to this user
|
||||
group and subscribe them. This is done by overriding the write method.
|
||||
"""
|
||||
_name = 'res.groups'
|
||||
_inherit = 'res.groups'
|
||||
_description = 'Access Groups'
|
||||
|
||||
def write(self, vals):
|
||||
res = super(ResGroups, self).write(vals)
|
||||
if vals.get('users'):
|
||||
# form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]}
|
||||
user_ids = [command[1] for command in vals['users'] if command[0] == 4]
|
||||
user_ids += [id for command in vals['users'] if command[0] == 6 for id in command[2]]
|
||||
self.env['mail.channel'].search([('group_ids', 'in', self._ids)])._subscribe_users_automatically()
|
||||
return res
|
||||
Loading…
Add table
Add a link
Reference in a new issue