Odoo - OpenERP - How to Give Access Rights To Custom Module or Create Security Groups for Custom Module ?
1) Create security folder inside our custom module.
This security module basically has two components i.e. module_name_security.xml and ir.model.access.csv and. Lets have a look at structure of both the files.
This file is basically use to define Groups. This file lists out all groups which will be utilized to define acess rights in ir.model.access.csv file.
<record model=”ir.module.category” id=”module_category_group_user”>
<field name=”description”>Name of Application</field>
<record model=”res.groups” id=”group_user_id”>
<field name=”category_id” ref=”module_category_group_user”/>
<field name=”users” eval=”[(4, ref(‘base.user_root’))]”/>
It is basically use to define access rights.This file lists out all models,various groups which will have access to these models and CRUD access for those models.
id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
id : It is the unique id for the permission.
name : It is the unique name for the permission.
model_id:id : the unique module name for which access needs to be given.
group_id:id : Unique Group name defined in module_name_security.xml
perm_read,perm_write,perm_create,perm_unlink: 1 for True, 0 for False to have read,write,create,delete access respectively.
2) Add groups to various elements of Module.
– Once we are done with Step 1,we can now add groups to various elements of our custom module.These elements can be Menuitems,Fields,Buttons etc.It helps to hide certain high level information from basic user and it can be shown to only higher authorities. Thus you can manage access to various modules and their elements.
3) Add both the files to __openerp__.py file.
– Finally we need to add both files (module_name_security.xml and ir.model.access.csv) to openerp descriptor file(__openerp__.py file).
Now we are done with adding access rights to our custom module. User can visit Users menu under settings and give necessary access right as per business needs to our custom module.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!