Introducing the to-do list project
Throughout this chapter, we will use an example project to illustrate the concepts being presented. The project will be to build a simple to-do list Odoo app.
We want the app to allow us to add new to-do items to a list and then mark them as completed. For example, we want to be able to add a Buy eggs to-do item to the list and then check an Is done? checkbox once the task is completed. Additionally, the to-do items should be private to each user – in other words, the current user should be able to access only their own to-do items. To make the project more interesting, we will introduce an additional complication – our to-do items should be able to include a list of the people involved in the task: the work team.
It is useful to think about our application by considering the tiers involved:
- Data tier: This tier is implemented through models.
- Business Logic tier: This tier is implemented through Python automation code.
- Presentation tier: This tier is implemented through views.
For the Data tier, we will create a To-do Item model. For the work team feature, we will make use of the built-in Contact model (also known as the Partner model). And we must not forget to configure the access control security for our new model.
The Business Logic tier will allow the basic create, read, update, and delete (CRUD) operations handled by the framework. In this case, we don't have additional automation requirements to support. We need to use Python code in developer modules to access the full power of the framework. We won't be doing that for developer modules yet, but the Technical menu provides access to the Automated Actions tool to implement business logic from the UI. We will look at an example of how to use this tool later in the chapter.
Finally, for the Presentation tier, we will add the menu option for our application and the views for the To-do Item model. The essential views for a business application are the list view (to browse the existing records) and the form view (to zoom in to a record and see all of its details). For user convenience, we can also add predefined filters to the list view's search box. The search box options are configured through a search view component.
We will follow these steps to build the to-do list app:
- Create the new model for the to-do items.
- Create the menu items to make them available to users.
- Configure the access control security.
- Create the list and form views for the to-do items.
The new To-do Item model should have these fields:
- A
Description
character field - An
Is Done?
flag, which is a Boolean field
Our specification for the app includes a work team feature: that is, the ability to select a list of people that will be working on the task. So, we need a model to represent people. Odoo includes the Contact model (with the technical name of res.partner
) to use for individual people, companies, and addresses.
The To-do Item model should include a work team field, which will allow us to select a list of people. We want to limit the people that can be selected to be part of work teams. For this, we will modify the Contact model to add a field for this: a Is Work Team?
flag. Only people with this flag enabled can be added to a work team.
For the work team feature, we need to add a field to the Contact model and the form view.
Before we go into the actual implementation, we will first discuss a few basic concepts relating to the Odoo framework, and then learn how to prepare an environment to work with.