Using delegation inheritance to copy features to another model

Traditional inheritance using _inherit performs in-place modification to extend the model's features.

However, there are cases where, rather than modifying an existing model, we want to create a new model based on an existing one to use the features it already has. This is done with Odoo's delegation inheritance, which uses the _inherits model attribute (note the additional s).

Traditional inheritance is quite different from the concept in object-oriented programming. Delegation inheritance, in turn, is similar, in that a new model can be created to include the features from a parent model. It also supports polymorphic inheritance, where we inherit from two or more other models.

We have a library with books. It's about time for our library to also have members. For a library member, we need all the identification and address data that's found in the Partner model, and we also want it to keep some information regarding the membership: a start date, a termination date, and a card number.

Adding those fields to the Partner model is not the best solution, since they will not be used for Partners that are not members. It would be great to extend the Partner model to a new model with some additional fields.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset