Book Image

Odoo Development Cookbook

By : Holger Brunn, Alexandre Fayolle, Daniel Reis
Book Image

Odoo Development Cookbook

By: Holger Brunn, Alexandre Fayolle, Daniel Reis

Overview of this book

Odoo is a full-featured open source ERP with a focus on extensibility. The flexibility and sustainability of open source is also a key selling point of Odoo. It is built on a powerful framework for rapid application development, both for back-end applications and front-end websites. The book starts by covering Odoo installation and administration, and provides a gentle introduction to application development. It then dives deep into several of the areas that an experienced developer will need to use. You’ll learn implement business logic, adapt the UI, and extend existing features.
Table of Contents (23 chapters)
Odoo Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 file is referenced by manifest data key:

        'data': [
            'security/library_security.xml',
            # ...
        ],
  2. We should have a security/library_security.xml data file, with a <data> section creating the security group...