Extending write() and create()
The Extending thebusiness 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 4,Creating Odoo addon Modules.
You will also need the security groups defined 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 Chapter 11, Access Security.
Modify the security/ir.model.access.csv
file to give write access to library users to books:
id,name,model_id:id,group_id:id,perm_read,perm_write...