Managing Access Rights Through the User Interface
- Navigate to Settings:
- 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
- Open the user for whom you want to set the access rights.
Under the "Access Rights" tab, you can assign the user to different groups. Each group has predefined access rights.
User Groups
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 create ir.model.access.csv and optionally use security.xml for record rules. Here is how you can do it:
- Define Access Control List (ACL) in ir.model.access.csv
Create or update the ir.model.access.csv file in your module's security 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 in security.xml
Record rules are used to define domain-based access controls. Create or update the security.xml file in your module's security 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.