Introducing the todo_ui module

In the previous chapter, we first created an app for personal to-dos, and then extended it so that the to-dos could be shared with other people.

Now we want to take our app to a new level by adding to it a kanban board and a few other nice user interface improvements. The kanban board will let us organize our tasks in columns, according to their stages, such as Waiting, Ready, Started or Done.

We will start by adding the data structures to enable that vision. We need to add stages and it will be nice if we add support for tags as well, allowing the tasks to be categorized by subject.

The first thing to figure out is how our data will be structured so that we can design the supporting Models. We already have the central entity: the to-do task. Each task will be in a stage, and tasks can also have one or more tags on them. This means we will need to add these two additional models, and they will have these relations:

  • Each task has a stage, and there can be many tasks in each stage.
  • Each task can have many tags, and each tag can be in many tasks.

This means that tasks have many to one relation with stages, and many to many relations with tags. On the other hand, the inverse relations are: stages have a one to many relationship with tasks and tags have a many to many relation with tasks.

We will start by creating the new todo_ui module and add the to-do stages and to-do tags models to it.

We've been using the ~/odoo-dev/custom-addons/ directory to host our modules. To create the new module alongside the existing ones, we can use these shell commands:

$ cd ~/odoo-dev/custom-addons
$ mkdir todo_ui
$ cd todo_ui
$ touch todo_model.py
$ echo "from . import todo_model" > __init__.py

Next, we should add the __openerp__.py manifest file with this content:

{  'name': 'User interface improvements to the To-Do app',
   'description': 'User friendly features.',
   'author': 'Daniel Reis',
   'depends': ['todo_app'] }

Note that we are depending on todo_app and not on todo_user. In general, it is a good idea to keep modules as independent as possible. When an upstream module is changed, it can impact all other modules that directly or indirectly depend on it. It's best if we can keep the number of dependencies low, and also avoid long dependency stacks, such as todo_uitodo_usertodo_app in this case.

Now we can install the module in our Odoo work database and get started with the models.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset