Adding features to a model using inheritance
One of the most important Odoo features is the ability of module add-ons to extend features that are defined in other module add-ons without having to edit the code of the original feature. This might be to add fields or methods, modify the existing fields, or extend the existing methods to perform additional logic.
According to the official documentation, Odoo provides three types of inheritance:
- Class inheritance (extension)
- Prototype inheritance
- Delegation inheritance
We will see each one of these in a separate recipe. In this recipe we will see Class inheritance (extension). It is used to add new fields or methods to existing models.
We will extend the built-in partner model res.partner
to add it to a computed field with the authored book count. This involves adding a field and a method to an existing model.
Getting ready
We will continue using the my_library
add-on module from the previous recipe.