Models and Python classes

Odoo models are represented by Python classes. In the preceding code, we have a Python class, Stage, based on the models.Model class, which defines a new Odoo model called todo.task.stage.

Odoo models are kept in a central registry, also referred to as a pool in the old API. It is a dictionary that keeps references to all the model classes available in the instance, and it can be referenced by a model name. Specifically, the code in a model method can use self.env['x'] to get a reference to a class representing the model x.

You can see that model names are important since they are the keys used to access the registry. The convention for model names is to use a list of lowercase words joined with dots, such as todo.task.stage ...

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.