Book Image

Odoo 12 Development Essentials - Fourth Edition

By : Daniel Reis
Book Image

Odoo 12 Development Essentials - Fourth Edition

By: Daniel Reis

Overview of this book

Odoo is one of the best platforms for open source ERP and CRM. Its latest version, Odoo 12, brings with it new features and updates in Python packages to develop more customizable applications with additional cloud capabilities. The book begins by covering the development essentials for building business applications. You will start your journey by learning how to install and configure Odoo, and then transition from having no specific knowledge of Odoo to being ready for application development. You will develop your first Odoo application and understand topics such as models and views. Odoo 12 Development Essentials will also guide you in using server APIs to add business logic, helping you lay a solid foundation for advanced topics. As you progress through the chapters, you will be equipped to build and customize your applications and explore the new features in Odoo 12, such as cloud integration, to scale your business applications. You will get insights into building business logic and integrating various APIs into your application. By the end of the book, you will be able to build a business application from scratch by using the latest version of Odoo.
Table of Contents (22 chapters)
Title Page
Packt Upsell
Foreword
Contributors
Preface
Index

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.