The model layer
Now that Odoo knows about our new module, let's add a simple model to it.
Models describe business objects, such as an opportunity, sales order, or partner (customer, supplier, and so on). A model has a list of attributes and can also define its specific business logic.
Models are implemented using a Python class derived from an Odoo template class. They translate directly to database objects, and Odoo automatically takes care of that when installing or upgrading the module. The framework component responsible for this is Object Relational Mapping (ORM).
Our module will be an application to manage a library, and the first feature we need is to manage the book catalogue, so at this point, this will be the only model we need to implement.
Â
Creating the data model
The Odoo development guidelines state that the Python files for models should be placed inside a models
subdirectory, and we should have one file for each model. So, we will create a models/library_book.py
file in the main...