Book Image

Odoo Development Essentials

Book Image

Odoo Development Essentials

Overview of this book

Table of Contents (17 chapters)
Odoo Development Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating models


For the to-do tasks to have a kanban board, we need stages. Stages are the board columns, and each task will fit into one of these columns.

Let's add the following code to the todo_ui/todo_model.py file:

# -*- coding: utf-8 -*-
from openerp import models, fields, api

class Tag(models.Model):
    _name = 'todo.task.tag'
    name = fields.Char('Name', 40, translate=True)

class Stage(models.Model):
    _name = 'todo.task.stage'
    _order = 'sequence,name'
    _rec_name = 'name'  # the default
    _table = 'todo_task_stage'  # the default
    name = fields.Char('Name', 40, translate=True)
    sequence = fields.Integer('Sequence')

Here, we created the two new Models we will be referencing in the to-do tasks.

Focusing on the task stages, we have a Python class, Stage, based on the class models.Model, defining a new Odoo model, todo.task.stage. We also defined two fields, name and sequence. We can see some model attributes, (prefixed with an underscore) that are new to us. Let's...