Enable Dark Mode!
By: Cybrosys Technologies

How to Set Compute Function for Field Using Odoo 17 Studio

Technical Odoo 17

In today's rapidly evolving business landscape, companies require flexible and customizable solutions to meet their unique operational needs. Odoo, a leading open-source ERP platform, empowers businesses with a wide range of modules and tools for streamlining processes, managing operations, and driving growth. Among these tools, Odoo Studio stands out as a powerful module that allows users to customize and extend Odoo applications without writing code. In this blog post, we'll explore the advantages of Odoo Studio and delve into the process of setting compute fields using this versatile tool.

In showcasing the dynamic capabilities of Odoo Studio for field customization, we created three fields within the Sale Order module: "Total Point," "Point from This Order," and "Initial Point."

How to Add a Custom Button in Odoo 17 POS Screen-cybrosys

Each field was meticulously configured with appropriate properties, ensuring alignment with the specific requirements of the business. Upon finalization, the changes were saved within Odoo Studio, seamlessly integrating the customized fields into the Sale Order module.

Continuing the customization journey within Odoo Studio, after selecting the "Total Point" field, proceed to enhance its functionality by configuring it as a compute field. To achieve this, navigate to the "Properties" tab and located the "More" button, which unlocks additional features for fine-tuning the field's behavior.

How to Add a Custom Button in Odoo 17 POS Screen-cybrosys

By clicking on the "More" button, a plethora of advanced options became available, enabling me to delve deeper into the configuration of the compute field. These options empower users to refine the field's behavior according to specific business requirements.

How to Add a Custom Button in Odoo 17 POS Screen-cybrosys

To configure the "Total Point" field as a computed field dependent on the "Initial Point" and "Point from This Order" fields in Odoo Studio, I would follow these steps:

In the "Dependencies" field, you need to specify the technical names of the fields on which the computed field relies. In this case, it's "Initial Point" and "Point from This Order." These technical names are usually represented as comma-separated paths

The compute function defines how the value of the "Total Point" field is calculated based on its dependencies. It typically involves Python code that computes the desired value. In this case, since you want the "Total Point" field to be the sum of the "Initial Point" and "Point from This Order" fields, you would write a compute function accordingly, as shown below.

In Python, there exist predefined variables tailored for use within computational functions.

* Self: Contains a set of records to compute within the context of a class or function.

* Datetime: Provides classes for working with dates and times.

* dateutil: An extension of the datetime module, offering additional functionalities such as timezone support and relative date calculations.

* time: For dealing specifically with time-related operations.

Additionally, within a class or function, access to other features can be achieved through the use of 'self' and 'self.env'.

How to Add a Custom Button in Odoo 17 POS Screen-cybrosys

By configuring the "Dependencies" field with the technical names of the dependent fields and defining the appropriate compute function, you ensure that the "Total Point" field updates dynamically based on changes to the "Initial Point" and "Point from This Order" fields, reflecting the sum of these values accurately.

How to Add a Custom Button in Odoo 17 POS Screen-cybrosys

In conclusion, the compute function in Odoo stands as a cornerstone feature, facilitating dynamic data computation within the ERP system. Through the compute function, fields can be intelligently calculated based on dependencies, allowing for real-time updates and accurate data representation. This feature plays a pivotal role in enhancing operational efficiency, automating processes, and ensuring data integrity within the organization. If you want to read more about how to Set Compute Function for Field Using Odoo studio module , refer to our previous blog about  Compute Function for Field Using Odoo.

If you need any assistance in odoo, we are online, please chat with us.


Leave a comment




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



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



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

Send Us A Message