Using Delegation inheritance to copy features to another Model

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

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

Traditional inheritance is quite different than 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 ...

Get Odoo Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.