Odoo 17 Access Rights

Posted By : Vineet Kundra | 26-Jul-2024

Odoo python

Loading...

Managing Access Rights Through the User Interface

  1. Navigate to Settings:
  2. Go to the Settings app.

Ensure that the developer mode is activated. You can activate developer mode by adding ?debug=1 to the URL or by clicking on the "Activate the developer mode" link at the bottom of the settings page.

Users & Companies

Navigate to Settings -> Users & Companies -> Users.

Manage User Roles

  1. Open the user for whom you want to set the access rights.
  2. Under the "Access Rights" tab, you can assign the user to different groups. Each group has predefined access rights.

User Groups

  1. Navigate to Settings -> Users & Companies -> Groups.

Here, you can see all the available groups and their permissions. You can create new groups or modify existing ones to customise access rights.

Managing Access Rights Through Custom Modules

To define access rights in a custom module, you need to createir.model.access.csv and optionally usesecurity.xml for record rules. Here is how you can do it:

  1. Define Access Control List (ACL) inir.model.access.csv

Create or update their.model.access.csv file in your module'ssecurity directory. This file defines which groups have what kind of access to each model.

Example:security/ir.model.access.csv

  • access_my_model_user: ID of the access control record.
  • my.model user: Name of the access control record.
  • model_my_model: ID of the model (you need to refer to the model's XML ID).
  • base.group_user: ID of the group (you can use predefined groups or your custom groups).
  • 1,0,0,0: Permissions for read (1), write (0), create (0), and delete (0).

2. Define Record Rules insecurity.xml

Record rules are used to define domain-based access controls. Create or update thesecurity.xml file in your module'ssecurity directory.

Example:security/security.xml

  • my_model_user_rule: ID of the record rule.
  • My Model User Rule: Name of the record rule.
  • model_my_model: Reference to the model.
  • domain_force: Domain expression to apply.
  • base.group_user: Group to which this rule applies.