O'Reilly logo

Odoo Development Cookbook by Daniel Reis, Alexandre Fayolle, Holger Brunn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Limit record access using record rules

A common need for an application is to be able to limit what records are available to each user on a specific model.

This is achieved using record rules. A record rule is a domain filter expression defined on a model that will then be added on every data query made by the affected users.

As an example, we will add a record rule on the Library books model so that the users in the employee group will only have access to books they created in the database.

Getting ready

This recipe assumes you have an instance ready, with my_module available, as described in Chapter 3, Creating Odoo Modules.

How to do it...

Record rules are added using a data XML file. To do so, perform the following steps:

  1. Ensure that the security/library_security.xml ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required