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 directory of the library_app module.

The Odoo official coding guidelines can be found at http://www.odoo.com/documentation/12.0/reference/guidelines.html. Another relevant coding standards document is the Odoo Community Association coding guidelines: https://github.com/OCA/maintainer-tools/blob/master/CONTRIBUTING.md.

Before that, we need to let Python know that the models directory should be used (imported in Python jargon). To do that, edit the module's main __init__.py file, like this:

from . ...

Get Odoo 12 Development Essentials - Fourth 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.