There's more...

With the _inherit traditional inheritance, it's also possible to copy the parent model's features to a completely new model. This is done by simply adding a _name class attribute with a different identifier. Here's an example:

class LibraryMember(models.Model): 
    _inherit = 'res.partner' 
    _name = 'library.member' 

The new model has its own database table with its own data that's totally independent from the res.partner parent model. Since it still inherits from the Partner model, any later modifications to it will also affect the new model.

In the official documentation, this is called prototype inheritance, but in practice, it is seldom used. The reason for this is that delegation inheritance usually answers to that need in a more efficient way, without the need to duplicate data structures. For more information on this, you can refer to the Using delegation inheritance to copy features to another model recipe of Chapter 5, Application Models.

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

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