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.
To define a compute method for the field, open the More option in the editor.
In this view, you can add dependent fields and define the Python code for the field.
We are defining the function as shown in the image below.
Now, the total quantity of products will be shown in the field.