Enable Dark Mode!
security-groups-access-rights-in-odoo-16.jpg
By: Archana V

Security Groups & Access Rights in Odoo 16

Technical Odoo 16

In this blog, let's discuss the security group and access rights in Odoo 16. Security access in Odoo is configured through security groups. Permissions are given to groups and then assigned to users. Here we have a custom module named Estate and inside of it we have a model estate.property. security-groups-access-rights-in-odoo-16-1-cybrosysNow we can see how we can add access rights in this model. Let's go to the pycharm. In the below-mentioned Screenshot, we can see the custom module Estate and inside the model directory, we can see the to define the model estate.property and it has some basic fields inside of it. Now we can see how to add access rights to this model.security-groups-access-rights-in-odoo-16-2-cybrosysHere we can create a folder named Security inside the custom module to add the security in the mentioned model. Inside the security directory, we can add the CSV file that is ir.model.access.csv.security-groups-access-rights-in-odoo-16-3-cybrosysIn Odoo, we create the security CSV file inside the file name ir.model.access.csv, so these records are created inside the model ir.model.access. Let us go to the UI and go to the settings; we have menu item access rights.security-groups-access-rights-in-odoo-16-4-cybrosysClick the menu Access rights, and this is the model where we created the Access Right records that is the model ir.model.access.security-groups-access-rights-in-odoo-16-5-cybrosysNow in the CSV file, we have defined like below.

id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1

The top line is defined as the column name of the particular model for access rights records; it will be defined like this. In the next line, we will create access rights records. So the second line is we have created access rights to our custom model. First of all, we have mentioned here the id of the access right record, and then we can see the name, and then we have specified the model to which we are giving the access rights to.

Here we specified the model like model_model_name. In the next section, we can give the group since we have to give any group here, which means we cannot restrict our corresponding model access to any group. The final section grants read, write, create, and unlink permissions. Permission is granted. If null, no permissions are granted.. Now let's go to the UI.

security-groups-access-rights-in-odoo-16-6-cybrosys

Here we can see the database login as Mitchel admin, then let's go to the custom module.

security-groups-access-rights-in-odoo-16-7-cybrosys

He can access the module, and then we can log out of the user and log in as another user, as marc demo, then move to the custom module, 

security-groups-access-rights-in-odoo-16-8-cybrosys

He can also have access to the custom module estate.property.Then we again log in as the Mitchell admin. Then we can see how we can set the access rights of the custom model to a particular group only. For that, we have to create an XML file inside the security folder and let's go to the UI and settings under users and company.

security-groups-access-rights-in-odoo-16-9-cybrosys

Let’s go to the groups. Here we can see all the groups existing inside Odoo, and here we have to create a group using code.

security-groups-access-rights-in-odoo-16-10-cybrosys

We will give field value to these fields' applications and names.

security-groups-access-rights-in-odoo-16-11-cybrosys

<odoo>
   <record id="estate_property_views_form_id" model="res.groups">
       <field name="name">Estate Property</field>
       <field name="category_id" ref="base.module_category_hidden"/>
   </record>
</odoo>

Using this, we can simply create the custom group. We can just search the groups in our custom group, and we can see the group is displayed in the group's menu.

security-groups-access-rights-in-odoo-16-12-cybrosys

Now we need to give the access rights for the custom model to only for these groups, so we can add the group to our CSV file. That is, we have to give the external id for the particular group. Let us go to the groups in UI; under access rights, we can see the new access rights we have created. Then we can add the users for this group. Now here we just add the user as Mitchell admin.

security-groups-access-rights-in-odoo-16-13-cybrosys

Here we give access only to Mitchell admin; he can access the model estate.property.

security-groups-access-rights-in-odoo-16-14-cybrosys

We can log out of the user and login as another user like marc demo .

security-groups-access-rights-in-odoo-16-15-cybrosys

Here we can see Marc demo is not able to see the model estate.property. This means the Marc demo does not access the records for the model estate.property.

This is how we can add the security groups and access rights for a particular model in Odoo 16.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment



whatsapp
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message