Beispiel #1
0
 def _check_system_group(self, vals):
     for key, val in vals.items():
         if is_boolean_group(key):
             val = get_boolean_group(key)
         if val and (is_boolean_group(key) or is_selection_groups(key)):
             groups = self.env['res.groups'].browse(val)
             groups |= groups.mapped('trans_implied_ids')
             if groups and groups.filtered(lambda r: r.system_group) and not self.env.user._is_superuser():
                 raise ValidationError('You are not allowed to assign the system group %s' % ', '.join(g.name for g in groups.filtered(lambda r: r.system_group)))
Beispiel #2
0
 def write(self, vals):
     write_res = super(Users, self).write(vals)
     sel_groups = [vals[k] for k in vals if is_selection_groups(k) and vals[k]]
     if vals.get('groups_id'):
         # form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]}
         user_group_ids = [command[1] for command in vals['groups_id'] if command[0] == 4]
         user_group_ids += [id for command in vals['groups_id'] if command[0] == 6 for id in command[2]]
         self.env['mail.channel'].search([('group_ids', 'in', user_group_ids)])._subscribe_users()
     elif sel_groups:
         self.env['mail.channel'].search([('group_ids', 'in', sel_groups)])._subscribe_users()
     return write_res