@@ -26,7 +26,7 @@
|
||||
]
|
||||
},
|
||||
'demo': [],
|
||||
'depends': ['hr', 'mail', 'base', 'survey', 'account'],
|
||||
'depends': ['hr', 'mail', 'base', 'survey', 'account', 'hr_payroll'],
|
||||
'installable': True,
|
||||
'application': True,
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user