mirror of
https://github.com/bringout/oca-ocb-mail.git
synced 2026-04-23 09:02:02 +02:00
19.0 vanilla
This commit is contained in:
parent
5df8c07b59
commit
daa394e8b0
2114 changed files with 564841 additions and 299642 deletions
|
|
@ -0,0 +1,25 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
from odoo.fields import Command
|
||||
|
||||
|
||||
class ResGroups(models.Model):
|
||||
""" Update of res.users class
|
||||
- add a preference about username for livechat purpose
|
||||
"""
|
||||
_inherit = "res.groups"
|
||||
|
||||
def write(self, vals):
|
||||
if vals.get("user_ids"):
|
||||
operator_group = self.env.ref("im_livechat.im_livechat_group_user")
|
||||
if operator_group in self.all_implied_ids:
|
||||
operators = operator_group.all_user_ids
|
||||
result = super().write(vals)
|
||||
lost_operators = operators - operator_group.all_user_ids
|
||||
# sudo - im_livechat.channel: user manager can remove user from livechat channels
|
||||
self.env["im_livechat.channel"].sudo() \
|
||||
.search([("user_ids", "in", lost_operators.ids)]) \
|
||||
.write({"user_ids": [Command.unlink(operator.id) for operator in lost_operators]})
|
||||
return result
|
||||
return super().write(vals)
|
||||
Loading…
Add table
Add a link
Reference in a new issue