Extending existing models

New models are defined through Python classes. Extending models is also done through Python classes, with help from an Odoo-specific inheritance mechanism, the _inherit class attribute. This _inherit class attribute identifies the model to be extended. The new class inherits all the features of the parent Odoo model, and we only need to declare the modifications to introduce.

In our todo.task model, we have a many-to-many field for the team of people (Partners) that will collaborate with us on that Task. We will now add to the Partners model the inverse of that relation, so that we can see, for each Partner, all the Tasks they are involved in.

The coding style guidelines recommend having a Python file for each model. ...

Get Odoo 11 Development Essentials - Third Edition 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.