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权限机制及使用
前言: 最近突然喜欢上一句诗:"宠辱不惊,看庭前花开花落:去留无意,望天空云卷云舒." 哈哈~,这个和今天的主题无关,最近只要不学习总觉得生活中少了点什么,所以想着围绕着最近面试过 ...
随机推荐
- Haproxy全透明代理
1. 系统环境搭建 操作系统Centos7 内核版本3.10 Centos7已自带TPROXY模块,不需要安装TPROXY 2. Haproxy下载,编译,安装,配置 下载地址 http://www. ...
- MXNET:权重衰减-gluon实现
构建数据集 # -*- coding: utf-8 -*- from mxnet import init from mxnet import ndarray as nd from mxnet.gluo ...
- MT7601 AP模式移植
MT7601 的 STA 模式和 AP 模式的驱动,是不一样的. 所以,需要另外移植驱动 驱动源码位置 https://github.com/eywalink/mt7601u 下载之后,先修改 Mak ...
- Envoy 代替nginx https://www.jianshu.com/p/0a1f67b42fdb
官方文档: https://www.envoyproxy.io/docs1.6.0版官方文档: https://www.envoyproxy.io/docs/envoy/v1.6.0/ 一. 编译和安 ...
- ESN 与 MEID
ESN (Electronic Serial Numbers):电子序列号.在CDMA 系统中,是鉴别一个物理硬件设备唯一的标识.也就是说每个手机都用这个唯一的ID来鉴别自己, 就跟人的身份证一样.一 ...
- 升级 Centos 6.5/6.7 的 php 版本
Centos 6.5/6.7 的 php 预设是用 5.3.3 这个版本号 wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-releas ...
- Nginx-介绍nginx的两篇博客
1. 一篇博客1.1)文章中间介绍配置文件的结构1.2)文章末尾可设置拒绝的ip,允许的ip博客地址:http://www.cnblogs.com/knowledgesea/p/5175711.htm ...
- 《转载》spring定时任务详解(@Scheduled注解)
本文转载自爱如指间沙 //每一个小时执行一次 @Scheduled(cron = "0 0 * * * ?") public void saveDailyScoreSchedule ...
- Mysql的复杂语句
简单的crud操作很容易,但是对于嵌套的查询语句,多表查询语句,以及条件查询语句,这些都很复杂,需要不断练习. limit a,b: 从a开始,长度为b. SELECT * FROM tb_quali ...
- Intelij的idea和pycharm的使用
idea是一个很复杂但是要页很好使用的工具,其集成了很多功能,也觉定了其很多的快捷键,要在使用得过程中总结其好处. 1.psvm:public static void main(){ } 2 ...