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 access to fields in models


In some cases we may need more fine grained access control and to limit the access to specific fields in a model.

It is possible for a field to be accessible only by specific security groups, using the groups attribute. We will show how to add to the Library Books model a field with limited access.

How to do it...

To add a field with access limited to specific security groups, perform the following steps:

  1. Edit the model file to add the field:

    private_notes = fields.Text(groups='base.group_system')
  2. Edit the view in the XML file to add the field:

    <field name="private_notes" />

That's it. Now upgrade the addon module for the changes in the model to take place. If you sign in with a user with no system configuration access, such as demo in a database with demonstration data, the Library books form won't display the field.

How it works...

Fields with the groups attribute are specially handled to check if the user belongs to any of the security groups indicated in...