In your Odoo custom module, create a security folder and add a file named ir.model.access.csv. This file is required to manage access rights for the model.
Structure of ir.model.access.csv
- id: A unique identifier for the access record.
- name: A descriptive name for the access record.
- model_id:id: The technical name of the model for which access rights are being defined.
- group_id:id (optional): The group to which access is granted. Leave this field empty to provide access to all groups.
- perm_read, perm_write, perm_create, perm_unlink: Permissions for Read, Write, Create, and Delete operations, represented as 1 (enabled) or 0 (disabled).
Example ir.model.access.csv File
csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sale_order_discount_wizard,Sale Order Discount Wizard,model_sale_order_discount_wizard,,1,1,1,1
Explanation of the Example
- id: access_sale_order_discount_wizard – A unique identifier for this access control record.
- name: Sale Order Discount Wizard – The name of the access control record.
- model_id:id: model_sale_order_discount_wizard – The technical model name for which the access control is applied.
- group_id:id: Left empty to allow access to all groups.
- perm_read, perm_write, perm_create, perm_unlink: All permissions are set to 1 (enabled), meaning users have full access to this model.
Steps to Apply Access Rights
- Create a security folder in your module if it doesn’t already exist.
- Add the ir.model.access.csv file with the appropriate content as shown above.
Update the __manifest__.py file to include the security file under the data key:
python
‘data’: [
‘security/ir.model.access.csv’,
],
Upgrade your module to apply the changes:
bash
./odoo-bin -u <module_name>
This ensures your model has the proper access rights configured in Odoo.