odoo权限管理
Odoo的权限的核心是权限组(res_groups)。对每个权限组,可以设置权限组的菜单表示,对象表示,记录规则表示,字段表示。
1.菜单/对象级别
设置哪些人可以访问哪些菜单/对象,对象的访问权限包括创建、读、写、删除。
2.记录级别
设置哪些人可以访问哪些记录,也就是设置表的查询条件。
3.字段级别
设置表中的字段的访问权限。
4.工作流级别
在工作流的每一步迁移中,设置哪些角色允许触发本迁移
菜单/对象级别:
|
1
2
3
4
5
|
模块下 security 目录有两个文件:xxx_security.xml、ir.model.access.csv。其中:xxx_security.xml文件定义组和组对菜单的访问权限,ir.model.access.csv定义组对对象的权限矩阵。<br><br> |
|
1
|
<span style=" padding: 0px !important; border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.8em !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; min-height: auto !important;">>x_security.xml文件:</span> |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<data noupdate="0"> <record model="ir.module.category" id="module_category_test"> <field name="name">测试</field> </record> <record model="res.groups" id="group_test_user"> <field name="name">测试用户</field> <field name="category_id" ref="module_category_test"/> </record> <record model="res.groups" id="group_test_manager"> <field name="name">测试管理</field> <field name="implied_ids" eval="[(4, ref('group_test_user'))]"/> <field name="category_id" ref="module_category_test"/> </record></data> |
Noupdate 表示,当模块升级时是否更新本条数据。
对于demo 数据,通常设置成noupdate=”1”,即不更新,不指定noupdate 的话,默认值是noupdate=”0”。
category_id表示:
group_test_user和group_test_manager属于module_category_test分组,并且只能选择其中一个。
ir.model.access.csv 文件:
示例:
id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
access_xxx xxxxx model_website_menu base.group_website_designer 1 1 1 1
model_id:id 对应的对象模型,
写法示例:website.model_website_config_settings
如果内容本身在website模块中则可以省略website.
后面则为模型的name将”.”替换成”-“的结果,在前面加model_
group_id:id 哪个组
perm_read、perm_write、perm_create、perm_unlink 增删改查权限。1 有权限 0 无权限
记录规则表示:
记录规则是一个记录模型”ir.rule”,关联到一个模型。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<record id="stock_picking_multi_company_rule" model="ir.rule"> <field name="name">stock.picking multi-company</field> <field name="model_id" ref="stock.model_stock_picking"/> <field name="global" eval="True"/> <field name="active" eval="False"/> <field name="domain_force">['|', '|', ('company_id', '=', False), ('company_id','child_of',[user.company_id.id]),('company_id','in',[c.id for c in user.company_ids])]</field></record><record id="product_template_public" model="ir.rule"> <field name="name">Public product template</field> <field name="model_id" ref="product.model_product_template"/> <field name="domain_force">[('website_published', '=', True), ("sale_ok", "=", True)]</field> <field name="groups" eval="[(4, ref('base.group_public')), (4, ref('base.group_portal'))]"/> <field name="perm_read" eval="True"/> <field name="perm_write" eval="False"/> <field name="perm_create" eval="False"/> <field name="perm_unlink" eval="False"/></record> Domain_force表示自定义Domain 表达式,用于过滤条件,含义是只能访问符合本过滤条件的记录。这里过滤条件是操作人必须是当前用户。 |
字段表示 :
字段表示权限可以指定权限组能访问记录里的哪个字段,可以在视图和对象上指定字段访问权限。
在视图上指定字段访问权限:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<field name="arch" type="xml"> <form string="Scheduled Products"> <group col="4"> <field name="name"/> <field name="product_id"/> <field name="product_qty"/> <field name="product_uom" groups="product.group_uom"/> <field name="product_uos_qty" groups="product.group_uos"/> <field name="product_uos" groups="product.group_uos"/> </group> </form></field>在字段对象定义时指定字段访问权限:_columns = { "gengo_private_key": fields.text("Gengo Private Key", copy=False, groups="base.group_system"), "gengo_public_key": fields.text("Gengo Public Key", copy=False, groups="base.group_user"), "gengo_comment": fields.text("Comments", help="This comment will be automatically be enclosed in each an every request sent to Gengo", groups="base.group_user"), "gengo_auto_approve": fields.boolean("Auto Approve Translation ?", help="Jobs are Automatically Approved by Gengo.", groups="base.group_user"), "gengo_sandbox": fields.boolean("Sandbox Mode", help="Check this box if you're using the sandbox mode of Gengo, mainly used for testing purpose."),} |
|
1
|
<span style=" padding: 0px !important; border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.8em !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; min-height: auto !important;">>隐藏的常用技巧:</span> |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
* 直接隐藏 <group name="owner" position="attributes"> <attribute name="invisible">True</attribute> </group>* 满足某些条件的隐藏 <xpath expr="//field[@name='parent_id']" position='attributes'> <attribute name="attrs">{'invisible': [('passenger','=', True)]}</attribute> </xpath> <group col="4" string='旅客信息' attrs="{'invisible': [('supplier','=', True)]}"></group> * 通过组来隐藏 <xpath expr="//field[@name='type']" position="attributes"> <attribute name="groups">base.group_no_one</attribute> </xpath>* 菜单的隐藏 <record model="ir.ui.menu" id="crm.menu_crm_opportunities"> <field eval="[(6,0, [ref('base.group_no_one'),])]" name="groups_id"/> </record> |
odoo权限管理的更多相关文章
- ODOO权限管理,在两个方面设置权限
转载参考https://zhuanlan.zhihu.com/p/29130388 在odoo中新建两个用户user1,user2 新建用户 建完了用户,记得编辑用户,设置密码. 然后以user1用户 ...
- odoo权限管理(二.记录管理)
规则保存在ir.rule模型表里,需要设置关联某个模型,关联很多组,访问权限控制和domian. 通过domain_force过滤出的一些记录来执行约束. 例子:经理只能删除状态为'cancel'的客 ...
- odoo开发笔记 -- odoo权限管理
odoo框架 整体权限可以分为4个级别: (1) 菜单级别: 不属于指定菜单所包含组的用,看不到相应菜单.不安全,只是隐藏菜单,若用户知道菜单ID,仍然可以通过指定URL访问(2) 对象级别: 对某个 ...
- odoo权限机制
转两篇关于权限的2篇文章,加深这方面的认识.注:后面附有原作者地址,希望不构成侵权. 第一篇:http://www.cnblogs.com/dancesir/p/6994030.html Odoo的权 ...
- Odoo权限控制
转载请注明原文地址:https://www.cnblogs.com/cnodoo/p/9278734.html 一:Odoo中的权限设置主要有以下5种 1)菜单.报表的访问权限 Odoo可以设置菜单项 ...
- Odoo权限控制详解
转载请注明原文地址:https://www.cnblogs.com/ygj0930/p/10826105.html 一:Odoo中的权限设置主要有以下5种 1)菜单.报表的访问权限 Odoo可以设置菜 ...
- Android权限管理之RxPermission解决Android 6.0 适配问题
前言: 上篇重点学习了Android 6.0的运行时权限,今天还是围绕着Android 6.0权限适配来总结学习,这里主要介绍一下我们公司解决Android 6.0权限适配的方案:RxJava+RxP ...
- Android权限管理之Android 6.0运行时权限及解决办法
前言: 今天还是围绕着最近面试的一个热门话题Android 6.0权限适配来总结学习,其实Android 6.0权限适配我们公司是在今年5月份才开始做,算是比较晚的吧,不过现在Android 6.0以 ...
- Android权限管理之Permission权限机制及使用
前言: 最近突然喜欢上一句诗:"宠辱不惊,看庭前花开花落:去留无意,望天空云卷云舒." 哈哈~,这个和今天的主题无关,最近只要不学习总觉得生活中少了点什么,所以想着围绕着最近面试过 ...
随机推荐
- TEST DESIGN TECHNIQUES: AN OVERVIEW
TEST DESIGN TECHNIQUES: AN OVERVIEW -Test note of “Essential Software Test Design” 2015-11-16 目录: 7. ...
- Go Revel - i18n(国际化)
##Messages `Messages`信息是对内容提供翻译的外部文本片段.revel提供了组织每一种语言文本片段的message文件.自动区域查找.基于cookie覆盖的消息嵌套和参数. 术语表: ...
- OpenWRT AR9331 mjpg-streamer 网络安装和离线ipk安装
OpenWRT AR9331 固件 我的摄像头ID为: root@Off-1CD0:/# lsusb Bus 001 Device 002: ID 1871:0101 OpenWRT支持的UVV摄像 ...
- How to get all Errors from ASP.Net MVC modelState?
foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelSt ...
- highCharts图表入门简介
一.Highcharts简介 Highcharts:功能强大.开源.美观.图表丰富.兼容绝大多数浏览器的纯js图表库 Highcharts是一款纯javascript编写的图表库,能够很简单便捷的在W ...
- 使用UIScrollView 结合 UIImageView 实现图片循环滚动
场景: 在开发工作中,有时我们需要实现一组图片循环滚动的情况.当我们使用 UIScrollView 结合 UIImageView 来实现时,一般 UIImageView 会尽量考虑重用,下面例子是以( ...
- DOTween 使用方法
参考链接: http://dotween.demigiant.com/documentation.php https://www.cnblogs.com/backlighting/p/5344047. ...
- word中替换【换行符】与【回车符】
- SpringBoot------Maven Install报错
报错信息: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin::compile (default-compil ...
- POJ 1958 Strange Towers of Hanoi
Strange Towers of Hanoi Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3784 Accepted: 23 ...