!11292 菜单权限

Merge pull request !11292 from 李鹏宇/dev_wang
This commit is contained in:
李鹏宇
2026-05-06 12:24:43 +00:00
committed by Gitee
3 changed files with 17 additions and 10 deletions
+1 -1
View File
@@ -26,7 +26,7 @@
]
},
'demo': [],
'depends': ['hr', 'mail', 'base', 'survey', 'account'],
'depends': ['hr', 'mail', 'base', 'survey', 'account', 'hr_payroll'],
'installable': True,
'application': True,
}
+6 -2
View File
@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="0">
<!-- 从默认用户模板中移除财务管理员权限组,新建用户不再默认带这些权限 -->
<!-- 从默认用户模板中移除财务管理员和薪资管理员权限组,新建用户不再默认带这些权限 -->
<record id="base.default_user" model="res.users">
<field name="groups_id" eval="[(3, ref('account.group_account_manager')), (3, ref('account.group_account_invoice'))]"/>
<field name="groups_id" eval="[
(3, ref('account.group_account_manager')),
(3, ref('account.group_account_invoice')),
(3, ref('hr_payroll.group_hr_payroll_manager')),
]"/>
</record>
</odoo>
+10 -7
View File
@@ -8,14 +8,17 @@ class ResUsers(models.Model):
@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))
group_refs = [
'account.group_account_manager',
'account.group_account_invoice',
'hr_payroll.group_hr_payroll_manager',
]
for ref in group_refs:
group = self.env.ref(ref, raise_if_not_found=False)
if group:
groups_to_remove.append((3, group.id))
if groups_to_remove:
users.sudo().write({'groups_id': groups_to_remove})
return users