Development Book V17: Access Rights

Access rights in a database system are essential regulations that dictate how a user can interact with specific objects. These rights adhere to the CRUD model, which encompasses Create, Read, Update, and Delete operations.

  • Create: Users with this privilege can generate values for a particular object.
  • Read: Only users with read permissions can view the values associated with an object.
  • Update: Users possessing update permissions can modify the values of a given object.
  • Delete: Users granted delete permissions can eliminate the values associated with an object.

Menus and views related to an object are only displayed to users if they have the corresponding access rights.

In a database, users are unique individuals identified by their login credentials. By default, a user has no access privileges. It's important to note that not all personnel in a firm are necessarily Odoo users; rather, Odoo users are individuals actively utilizing the program.

Odoo employs two primary data-driven strategies for controlling data access: groups and custom code. Users can belong to multiple groups, and security mechanisms are linked to these groups, thereby applying security measures to users.

When creating a custom model in Odoo, access for users to this model is granted through the security directory in the corresponding module. The ir.model.access.csv file is crucial for defining access rights.

Consider the following example:

id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_test_model, access_test_model, model_test_model, base.group_user,1,0,0,0

Here's a breakdown:

  • id: External identifier.
  • name: Name of ir.access.model.
  • model_id/id: Refers to the model to which the access right applies, typically formatted as model_< model_name>.
  • group_id/id: Refers to the group to which the access right applies.
  • perm_read, perm_write, perm_create, perm_unlink: Specify read, write, create, and unlink permissions.

Finally, include the ir.model.access.csv file in the __manifest__.py file:

'data': [
   'security/ir.model.access.csv',
],
whatsapp_icon
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