资金管理权限

This commit is contained in:
李鹏宇
2026-05-07 17:58:08 +08:00
parent 32508f72b9
commit ab05ae04d8
3 changed files with 2 additions and 40 deletions
-1
View File
@@ -54,7 +54,6 @@
'images': ['static/description/banner.png'],
'depends': [
'web',
'hr',
],
'summary': '''
Easy setup user role base on multi security groups.
+2 -30
View File
@@ -59,27 +59,6 @@ class ResUsers(models.Model):
If no role is defined on the user, its groups are let untouched unless
the `force` parameter is `True`.
"""
# 定义受保护的群组,这些群组不会被角色自动添加或移除
protected_group_refs = [
# 财务相关群组
'account.group_account_manager',
'account.group_account_invoice',
'account.group_account_user',
'account.group_readonly',
# 薪资相关群组
'hr_payroll.group_hr_payroll_manager',
'hr_payroll.group_hr_payroll_user',
'yuthon_salary.group_jtbb_user',
'yuthon_salary.group_wg_user',
'yuthon_salary.group_lc_user',
'yuthon_salary.salary_rule_confirm_group',
]
protected_group_ids = []
for ref in protected_group_refs:
group = self.env.ref(ref, raise_if_not_found=False)
if group:
protected_group_ids.append(group.id)
role_groups = {}
# We obtain all the groups associated to each role first, so that
# it is faster to compare later with each user's groups.
@@ -99,15 +78,8 @@ class ResUsers(models.Model):
role = role_line.role_id
group_ids += role_groups[role]
group_ids = list(set(group_ids)) # Remove duplicates IDs
# 移除受保护的群组,不让角色管理它们
group_ids = [gid for gid in group_ids if gid not in protected_group_ids]
# 获取用户当前非受保护的群组
user_non_protected_groups = [g.id for g in user.groups_id if g.id not in protected_group_ids]
groups_to_add = list(set(group_ids) - set(user_non_protected_groups))
groups_to_remove = list(set(user_non_protected_groups) - set(group_ids))
groups_to_add = list(set(group_ids) - set(user.groups_id.ids))
groups_to_remove = list(set(user.groups_id.ids) - set(group_ids))
to_add = [(4, gr) for gr in groups_to_add]
to_remove = [(3, gr) for gr in groups_to_remove]
groups = to_remove + to_add
-9
View File
@@ -15,18 +15,9 @@ class ResUsers(models.Model):
# 新建用户后确保移除财务和薪资管理员权限组
groups_to_remove = []
group_refs = [
# 财务相关群组
'account.group_account_manager',
'account.group_account_invoice',
'account.group_account_user',
'account.group_readonly',
# 薪资相关群组
'hr_payroll.group_hr_payroll_manager',
'hr_payroll.group_hr_payroll_user',
'yuthon_salary.group_jtbb_user', # 集团本部用户
'yuthon_salary.group_wg_user', # 物管公司用户
'yuthon_salary.group_lc_user', # 粮储公司用户
'yuthon_salary.salary_rule_confirm_group', # 工资批次确认
]
for ref in group_refs:
group = self.env.ref(ref, raise_if_not_found=False)