Odoo 16 Studio Book - DEFINE COMPUTE METHOD

Odoo allows users to calculate field values in two ways. One is dependent on other fields, and the other is not dependent on any other fields. The Odoo Studio module helps create compute fields easily in the UI. We can discuss a computation function for a field to show the total product quantity of that order.

Now we can add the field Total Product Quantity. In this field, we need to calculate the total product quantity.

odoo-studio

After opening the studio window, we need to select this field. Under Properties, we have an option ‘More’.

odoo-studio

After clicking the "More" option, we need to define the dependencies and compute.

odoo-studio

In the dependencies, you should write fields that are related to the compute method.

The compute function returns a value after the calculation for each record.

There are some predefined variables available in Odoo.

  • Self: The set of records to compute
  • Datetime: Supply classes to work with date and time
  • Dateutil: Using the dateutil module, we can expand the datetime module. When we need to show the timezone or calculate the relative delta between two dates, they are possible to use dateutil package.
  • Python module for dealing with time
odoo-studio

In this way, we can add compute method for any field.

odoo-studio
whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message