Adding Access Security
When adding a new data model, you need to define who can create, read, update, and delete records. When creating a totally new application, this can involve defining new user groups.
This recipe builds on the Library Book
Model from the previous recipes and defines a new group of users to control who can work book records.
Getting ready
The addon module implementing the library.book
model, provided in the previous recipe, is needed. The paths used are relative to our addon module location (for example, ~/odoo-dev/local-addons/my_module/
).
How to do it...
The security rules we want to add in this recipe are as follows:
- Everyone will be able to read library book records
- A new group of users called "Librarians" will have the right to create, read, update, and delete book records
To implement this, you need to perform the following steps:
- Create a file called
security/groups.xml
with the following content:
<?xml version="1.0" encoding="utf-8"?> <odoo> <record id...