Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Odoo 12 Development Essentials

You're reading from   Odoo 12 Development Essentials Fast-track your Odoo development skills to build powerful business applications

Arrow left icon
Product type Paperback
Published in Dec 2018
Publisher Packt
ISBN-13 9781789532470
Length 404 pages
Edition 4th Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Daniel Reis Daniel Reis
Author Profile Icon Daniel Reis
Daniel Reis
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Quick Start Using the Developer Mode FREE CHAPTER 2. Preparing the Development Environment 3. Your First Odoo Application 4. Extending Modules 5. Import, Export, and Module Data 6. Models – Structuring the Application Data 7. Recordsets – Working with Model Data 8. Business Logic – Supporting Business Processes 9. External API – Integrating with Other Systems 10. Backend Views – Designing the User Interface 11. Kanban Views and Client-Side QWeb 12. Reports and Server-Side QWeb 13. Creating Website Frontend Features 14. Deploying and Maintaining Production Instances 15. Assessments 16. Other Books You May Enjoy

Introducing the to-do list project

The TodoMVC (http://todomvc.com/) project provides a comparison between multiple JavaScript frameworks by implementing the same simple to-do application in each of them. Inspired by this, we will go through the experience of building a simple to-do application with Odoo.

It should allow us to add new to-do items, and then mark them as completed. For example, you could add to-do items to the list, such as Buy eggs, and then check an Is Done? box once they are completed. The To-do Items should be private to the current user, so that you will only be able to access your own to-do items.

This should be enough for a simple to-do application, but to make it a little more interesting we will introduce a couple of complications. Our to-do list items should be able to include a list of people involved in the task, the work team.

It is useful to think about our application by considering several layers involved:

  • The data tier: Implemented through models
  • The logic tier: Implemented through automation code
  • The presentation tier: Implemented through views

For the data tier, we need a To-do Item model. We will also make use of the built-in partner (or contacts) model to support the work team feature. We must not forget to configure the access control security for our new model.

The logic tier used here will be the basic CRUD operations handled by the framework, and we don't have in our requirements any additional automation to support. To access the full power of the framework, we need to use Python code in developer modules. While we can't do that yet, the developer menu does provide some tools for us to implement some business logic from the user interface, the automate actions. We will work on a simple example of how to use them.

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, where we can browse the existing records, and the form view, where we can zoom in to a record and see all the details. For better usability, we can also add preconfigured filters to the search box, available in the list view. The available search options are also considered a view, so this can be done through a search view.

The following are the steps to create a to-do list:

  1. First, we will create a new model for to-do items, and then make it available to users by adding a to-do top menu for it.
  2. Next, we will create the list and form views for the To-do Items model. This new model should have these fields:
    • Description text field
    • Is Done? flag (a Boolean field)

Our specification for the application includes the ability to select a list of people that will be working on the task, so we need a Model to represent people. Fortunately, Odoo includes out of the box a model for this—the partner model (res.partner is its technical name), used to store individual people, companies, and addresses.

And only particular persons are selectable for this work team. This means that we need to modify the partner model to add this new Is Work Team? flag.

So, the To-do Items model should also include the work team field, with a list of people. The linked people are selectable from the partners/contacts that have the Is Work Team? flag enabled.

As a summary, this is what we will need to do:

  • Add a field to the partner model and form view
  • Create a To-do Item model
  • Create a to-do application menu item
  • Create a to-do Item user interface: List and form view, and UI search options
  • Create access security: Group, access control lists (ACL), and Record Rules

Before we go into the actual implementation, we will first discuss a few basic concepts about the Odoo framework, and then learn how to prepare an environment to work with.

You have been reading a chapter from
Odoo 12 Development Essentials - Fourth Edition
Published in: Dec 2018
Publisher: Packt
ISBN-13: 9781789532470
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime