今天来介绍Group的写法,Group用意就是分你需要的权限群组,将需要这些权限的人加入,最後再把权限分配给Group,今天以学生的资料权限,我们分为主任、老师、志工三个群组。
在security底下增加res_student_group.xml,记得__mainfest__内要填入path
<odoo>
<data>
<record model="ir.module.category" id="module_category_education">
<field name="name">Education</field>
<field name="description">About education</field>
</record>
<record model="res.groups" id="group_school_teacher">
<field name="name">Teacher</field>
<field name="category_id" ref="module_category_education"/>
</record>
<record model="res.groups" id="group_school_director">
<field name="name">Director</field>
<field name="category_id" ref="module_category_education"/>
</record>
<record model="res.groups" id="group_school_volunteer">
<field name="name">Volunteer</field>
<field name="category_id" ref="module_category_education"/>
</record>
</data>
</odoo>
首先我们先增加一个group category,让我们的群组有个类别,以便日後好管理这些权限
category的model为ir.module.category
,id
不重复即可。
接下来就是定义group,model固定为res.groups
,其他也都依需求定义,最後记得把刚刚设定的category record指向category_id栏位内。
重新启动後,在Settings/Users & Companies/Groups内便能看到,记得Groups必须开启开发者模式:
接着我们结合昨天所说,将ir.model.access.csv
重写:
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_res_student_director,access_res_student,res.student,model_res_student,group_school_director,1,1,1,1,
access_res_student_teacher,access_res_student_teacher,model_res_student,group_school_teacher,1,1,1,0
access_res_student_volunteer,access_res_student_volunteer,model_res_student,group_school_volunteer,1,0,0,0
如此以来就如昨天所说,志工层级只能读取员工资料,老师层级可以增加及修改,只有主任层级才有删除的功能,剩下要做的就是将使用者加入各自的group,我们的权限设定就完成了。
今天就介绍到这边,明天我们来将Model加入至Odoo的Menu当中。
<<: [Day 13] tinyML开发框架(一):TensorFlow Lite Micro初体验(下)
>>: 【Day 13】粗暴後门,Duck 不必 - Windows 简单後门
JAVA - Windows 10 建立 Maven 专案并执行 参考资料 参考资料: (二)mav...
今天一样跟着网路上的大神 重新认识 Vue.js | Kuro Hsu 3-2 Vue SFC 单一...
详细可以参考这个网站页面的整理,下面是我协杠玩WordPress半年来的心得 https://109...
今天要来讲解TypeScript(TS)的选择性属性(Optional Properties), 在...
非常的简易透过 Spring boot 提供的注解我们可以轻松地宣告和使用 @Data @AllAr...