More Model inheritance mechanisms
Previously, we saw the basic extension of Models, called classic inheritance, in the official documentation. This is the most frequent use of inheritance, and the easiest way to think about it is as an in-place extension. You take a Model and extend it. As you add new features, they are added to the existing Model. A new Model isn't created.
Â
Â
We can also inherit from multiple parent Models, setting a list of values to the _inherit
attribute. Most of the time, this is done with mixin classes. Mixin classes are Models that implement generic features to be reused. They are not expected to be used on their own, like regular Models, and are like a container of features, ready to be added to other Models.
If, along with _inherit
, we also use the _name
attribute with a value different from the parent Model, we get a new Model by reusing the features from the inherited one, with its own database table and data. The official documentation calls this prototype inheritance...