Creating the data model

The Odoo development guidelines state that the Python files for models should be placed inside a models subdirectory. So, we will create a models/todo_task_model.py file in the main directory of the todo_app module.

The Odoo official coding guidelines can be found at http://www.odoo.com/documentation/11.0/reference/guidelines.html. Another relevant coding standards document is the Odoo Community Association coding guidelines at 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). To do that, edit the module's main __init__.py file like this:

from . import models

We also need to add a models/__init__.py file, ...

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.