Creating an application model
Now that Odoo knows about our new module, let's start by adding to it a simple model.
Models describe business objects, such as an opportunity, a sales order, or a partner (customer, supplier, and so on.). A model has a list of attributes and can also define its specific business.
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.
Some consider it good practice to keep the Python files for models inside a models
subdirectory. For simplicity we won't be following that here, so let's create a todo_model.py
file in the todo_app
module main directory.
Add the following content to it:
# -*- coding: utf-8 -*- from openerp import models, fields class TodoTask(models.Model): _name = 'todo.task' name = fields.Char('Description', required=True) is_done = fields.Boolean('Done?') active = fields.Boolean...