Give Access Rights To Custom Module

Give Access Rights To Custom Module. Odoo is made up of various core modules also known as official modules.These modules are related to different business processes such Sale, Purchase, Accounting, Human Resources etc. In an organization with different departments and number of users belonging to those departments, it always crucial for management to have proper access rights defined per module. Odoo security features maps this requirement clearly and in a user-friendly manner.

Most of the times, we need to build up entirely new module in order to match requirements from client.So it is required to maintain access rights from the custom module. We were working on one of the projects where we had to create a custom module as per needs.The procedure is as follows.

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. Let us have a look at the structure of both the files.


This file is basically used to define Groups. This file lists out all groups which will be utilized to define access rights in ir.model.access.CSV file.

<record model=”ir.module.category” id=”module_category_group_user”>
<field name=”name”>User</field>
<field name=”description”>Name of Application</field>
<field name=”sequence”>20</field>
<record model=”res.groups” id=”group_user_id”>
<field name=”name”>User</field>
<field name=”comment”>Comment.</field>
<field name=”category_id” ref=”module_category_group_user”/>
<field name=”users” eval=”[(4, ref(‘base.user_root’))]”/>
ir.model.access.csv :

It is basically used 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 a 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 file.
– Finally we need to add both files (module_name_security.xml and ir.model.access.csv) to OpenERP descriptor file( file).

Now we are done with adding access rights to our custom module. A user can visit Users menu under settings and give necessary access right as per business needs to our custom module.