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权限机制及使用
前言: 最近突然喜欢上一句诗:"宠辱不惊,看庭前花开花落:去留无意,望天空云卷云舒." 哈哈~,这个和今天的主题无关,最近只要不学习总觉得生活中少了点什么,所以想着围绕着最近面试过 ...
随机推荐
- Android Studio 运行出现 Multiple dex files define Landroid/support/annotation/AnimRes 解决方法
引入的工程的android-support-v4.jar版本跟自己工程的android-support-v4.jar的版本不一样
- nginx配置http为1.0到1.1
转载自:https://blog.csdn.net/u014558668/article/details/79237020 需求:接口通过nginx转发服务器,接收不到数据,但是测试环境是好的: 环境 ...
- CSS实现响应式全屏背景图
body { /* 加载背景图 */ background-image: url(images/background-photo.jpg); /* 背景图垂直.水平均居中 */ background- ...
- A Tour of ParallelExtensionsExtras
Throughout the development of Parallel Extensions for the .NET Framework 4, we've come across a myri ...
- CentOS6上实现Tomcat8 service启动,并查看status
service配置脚本,“/etc/init.d/tomcat”,实现通过"service tomcat status " 查看tomcat状态,并输出PID,见脚本 # desc ...
- CentOS6.x 升级到 CentOS7.x(测试)
博文来源:http://leyewen.blog.163.com/ 官方升级教程:http://wiki.centos.org/TipsAndTricks/CentOSUpgradeTool ...
- 描述: http通讯基础类
package com.founder.ec.web.util.payments.payeco.http; import com.founder.ec.web.util.payments.payeco ...
- ganglia分布式监控部署
一.介绍 Ganglia是由UC Berkeley发起的一个开源监控项目,设计用于监控数以千几的节点.每台服务器都运行一个收集和发送监控数据名为gmond的守护进程.它将从操作系统和指定 ...
- css3整理--Animation
animation语法: 1.动画的定义 @keyframes IDENT { from { Properties:Properties value; } Percentage { Propertie ...
- JS正则校验
/** 用途:检查输入字符串是否为空或者全部都是空格 输入:str:字符串 返回: 如果全是空返回true,否则返回false */ function isNull(str) { if (str == ...