Odoo 19 Studio Book : Define Compute Method

In Odoo, field calculations can be handled in two different ways: by relying on other fields or by functioning independently. In this chapter, we will explore how to define a computed field using the Studio module.

As an example, let us see how to define a compute method to calculate the total quantity of Sale Orders. To begin with, we first need to create a quantity field in the Sale Order model.

Odoo 19 Project

To define a compute method for the field, open the More option in the editor.

Odoo 19 Project

In this view, you can add dependent fields and define the Python code for the field.

Odoo 19 Project

We are defining the function as shown in the image below.

Odoo 19 Project

Now, the total quantity of products will be shown in the field.

Odoo 19 Project
WhatsApp