More model inheritance mechanisms
The previous section discussed classic inheritance, which can be seen as an in-place extension. This is the most frequently used approach, but the Odoo framework also supports a few other extension mechanisms that are useful in other cases.
These are delegation inheritance, prototype inheritance, and the use of mixins:
- Delegation inheritance embeds another model in the inheriting one. For example, a
User
record embeds aPartner
record, so that aUser
record has all the fields available for thePartner
records, plus the fields specific to theUser
records. It is used through the_inherits
attribute. - Prototype inheritance creates a new model by copying the features from the inherited model and has a database table and data. It is not used often and it is never used in the Odoo-included add-on modules. It is used to set
_inherit
with the model to copy and the_name
attribute with the identifier for the new model to be created. - Mixin...