Book Image

Odoo 15 Development Essentials - Fifth Edition

By : Daniel Reis
4.5 (2)
Book Image

Odoo 15 Development Essentials - Fifth Edition

4.5 (2)
By: Daniel Reis

Overview of this book

Odoo is fast becoming the reference open source platform for business applications thanks to the fact that it provides the infrastructure needed for developers to deliver software solutions for any business process quickly. Odoo's layered module approach makes it particularly effective for combining and extending features. This updated fifth edition is a tutorial-style introduction to essential Odoo development topics. The book starts by covering the development essentials for building business applications and takes you through Odoo installation and configuration, gradually transitioning from having no specific knowledge of Odoo to being ready for application development. You'll then learn how to develop your first Odoo application, while covering topics such as models and views. Later chapters will get you up to speed with using server APIs to add business logic, helping you lay a solid foundation for advanced topics. As you progress, you’ll get equipped to build and customize your applications and explore the new features available in Odoo 12 and beyond, such as in-memory ORM and computed writable fields. Finally, you’ll gain insights into building business logic and using the Odoo API to integrate with various applications. By the end of this book, you’ll be able to build business apps from scratch using the latest version of Odoo.
Table of Contents (22 chapters)
1
Section 1: Introduction to Odoo Development
6
Section 2: Models
9
Section 3: Business Logic
13
Section 4: Views
18
Section 5: Deployment and Maintenance

Enabling the developer tools

The Odoo developer tools are needed for us to implement our project. They are made available by enabling the developer mode.

The developer mode is useful for inspecting and modifying the current Odoo configurations. It allows us to customize Odoo apps directly from the UI and is a quick way to make changes and add features. It can be used for making small modifications, such as adding a custom field, or it can be used for larger customizations, such as creating an application with its own menus, views, and underlying data model.

Caution

The developer mode exposes internal configurations for Odoo apps and allows them to be changed. With great power comes great responsibility, so be careful with the changes made. Always try these changes on a copy database before making them in a live system. If things go wrong, there is a chance that an upgrade of the affected app – or the base module – can resolve the issues, but this is not guaranteed.

Making customizations through the developer tools has some limitations compared to the programming tools covered throughout the rest of the book. For example, the developer tools can't add or extend the default ORM methods.

The customizations made with the developer mode (and with the Odoo Studio app, for that matter) can't be easily integrated into a structured development workflow with version control, automated tests, and QA/staging/production code promotion workflows.

The developer mode features will be used in this chapter as a way to introduce how the application configuration data is organized in the Odoo framework and how the developer mode can be leveraged for simple customizations or prototyping solutions.

Enabling the developer mode

For Odoo 13 and later, the developer mode is enabled on the Settings | General Settings page. Near the bottom, you will find a Developer Tools section. There, you will find the Activate the developer mode link. Clicking on this enables the developer mode features for the current browser window, as shown in the following screenshot:

Figure 1.3 – The Developer Tools options section on the Settings page

Figure 1.3 – The Developer Tools options section on the Settings page

Note that the General Settings menu option is only visible if there is at least one app installed. If it is not available, install an app such as Contacts or CRM (or any other of your choice).

Changes in Odoo 13

In Odoo versions 10 to 12, the developer mode is enabled on the Settings | Dashboard page in the lower-right corner. For Odoo 9 and before, the developer mode is activated in the About dialog window, which is available from the User menu in the upper-right corner of the web client.

Once the developer mode is enabled, we will see the following menus made available:

  • On the top menu bar, the developer tools bug icon will be on the right-hand side next to the Conversations and Activities icons.
  • On the Settings app, the Technical and Translations menu items will be visible on the top bar.
Figure 1.4 – The Settings page with the developer mode enabled

Figure 1.4 – The Settings page with the developer mode enabled

The developer mode also enables additional information on the web client views – when hovering the mouse pointer over a field, a tooltip will display technical information relating to it.

Note

The developer mode can also be enabled by directly editing the current URL without having to leave the current page to open the settings. Edit the URL to change the .../web#... part to insert .../web?debug=1#... in its place. For example, http://localhost:8069/web#home would become http://localhost_8069/web?debug=1#home.

Using the developer mode with assets

For faster load times, the web client minifies the JavaScript and CSS assets into compact files. Unfortunately, that makes web client debugging nearly impossible.

The Activate the developer mode (with assets) option prevents this minification and loads the web assets in individual, non-minified files. This is useful to debug the web client itself, but it comes at the expense of making the web client navigation slower.

Tip

Both Firefox and Chrome browsers have extensions available providing a button to conveniently enable and disable the developer mode in Odoo. Search for Odoo Debug in their extension stores.

About Odoo Studio

It is also worth noting that both the Odoo EE and the Odoo SaaS edition offer the Odoo Studio app – an interactive application builder. We won't be using it because it's not available for the Odoo CE that is used as the example edition in this book.

Odoo Studio provides a user-friendly UI for the same interactive development features introduced in this chapter – along with a few extra features, such as the ability to export our customizations to a file.

Here, we will be using the developer mode (sometimes referred to as the debug mode) and the Technical menu, which are both available in all Odoo editions. Most of what can be built using Odoo Studio can also be built with these tools – albeit in a more technical way that is not as easy for non-developers.