菜单权限
This commit is contained in:
@@ -63,6 +63,21 @@ class ResUsers(models.Model):
|
||||
|
||||
wecom_fields = fields.Char(string="免登录验证字段", compute='_compute_wecom_fields', stroe=True)
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
users = super().create(vals_list)
|
||||
# 新建用户后移除财务管理员权限组
|
||||
groups_to_remove = []
|
||||
group_manager = self.env.ref('account.group_account_manager', raise_if_not_found=False)
|
||||
group_invoice = self.env.ref('account.group_account_invoice', raise_if_not_found=False)
|
||||
if group_manager:
|
||||
groups_to_remove.append((3, group_manager.id))
|
||||
if group_invoice:
|
||||
groups_to_remove.append((3, group_invoice.id))
|
||||
if groups_to_remove:
|
||||
users.sudo().write({'groups_id': groups_to_remove})
|
||||
return users
|
||||
|
||||
@api.depends('login')
|
||||
def _compute_wecom_fields(self):
|
||||
for i in self:
|
||||
@@ -179,6 +194,16 @@ class ResUsers(models.Model):
|
||||
try:
|
||||
with self.env.cr.savepoint():
|
||||
user_id = template_user.sudo().with_context(no_reset_password=True).copy(values)
|
||||
# 移除财务管理员权限组
|
||||
groups_to_remove = []
|
||||
group_manager = self.env.ref('account.group_account_manager', raise_if_not_found=False)
|
||||
group_invoice = self.env.ref('account.group_account_invoice', raise_if_not_found=False)
|
||||
if group_manager:
|
||||
groups_to_remove.append((3, group_manager.id))
|
||||
if group_invoice:
|
||||
groups_to_remove.append((3, group_invoice.id))
|
||||
if groups_to_remove:
|
||||
user_id.sudo().write({'groups_id': groups_to_remove})
|
||||
return user_id
|
||||
except Exception as e:
|
||||
_logger.exception("OAuth Wechat: 微信访问用户【UserId:%s】自动创建失败【Odoo错误:%s】!" % (userid, ustr(e)))
|
||||
|
||||
Reference in New Issue
Block a user