首先在security目录下新增security.xml文件,并添加__manifest__.py引用,xml内容如下
<?xml version="1.0" ?> <odoo> <data> <record id="module_xxx_title" model="ir.module.category"> <field name="name">标题</field> </record> <record id="xxx_user_group_1" model="res.groups"> <field name="name">用户组1</field> <field name="category_id" ref="module_xxx_title"/> </record> <record id="xxx_user_group_2" model="res.groups"> <field name="name">用户组2</field> <field name="category_id" ref="module_xxx_title"/> </record> <record id="xxx_user_group_3" model="res.groups"> <field name="name">用户组3</field> <field name="category_id" ref="module_xxx_title"/> </record> </data> </odoo>
然后在ir.model.access.csv文件中创建与model的对应关系
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_xxx_employee,xxx.employee,model_xxx_employee,xxx.xxx_user_group_1,1,1,1,1 access_xxx_employee,xxx.employee,model_xxx_employee,xxx.xxx_user_group_2,1,0,0,0 access_xxx_employee,xxx.employee,model_xxx_employee,xxx.xxx_user_group_3,1,0,0,0
程序重启后,可以在“设置” - “用户和公司”-“群组”中看到创建的用户组1/2/3。打开一个用户组,可以在“访问权限”标签中看到model列表。
标签:用户组,xxx,perm,id,odoo,employee,model,代码 From: https://www.cnblogs.com/pythonClub/p/17379030.html