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

Extending write() and create()


The Extending the business logic defined in a Model recipe showed how to extend methods defined on a model class. If you think about it, methods defined on the parent class of the model are also part of the model. This means that all the base methods defined on models.Model (actually on models.BaseModel, which is the parent class of models.Model) are also available and can be extended.

This recipe shows how to extend create() and write() to control access to some fields of the records.

Getting ready

We will extend on the library example from the my_module addon module in Chapter 3, Creating Odoo Modules.

You will also need the security groups defined in Chapter 10, Accessing Security in the Creating security Groups and assigning them to Users recipe and the access rights defined in the Adding security access to models recipe from the same chapter.

Modify the file security/ir.model.access.csv to give write access to library users to books:

id,name,model_id:id,group_id...