odoo technical video
Video Tutorial

Trigger Functions on Button Click in Odoo 16

MAR 28,2023


In Odoo 16, you can trigger functions on button click by defining a method in your model and linking it to the button in your view. This allows you to execute custom logic when a user clicks a button in the user interface.

To trigger a function on button click, follow these steps:

1. Define the method in your model that you want to execute when the button is clicked. The method should take one argument, which is the record set of the current record. 

2.In your view, add a button element and define its attributes. The "name" attribute specifies the name of the method to call when the button is clicked. The "string" attribute specifies the label that will be displayed on the button. The "type" attribute specifies the type of action to perform, which should be "object" for methods that modify the current record.

3.Add the button to the appropriate view(s) for your model. You can add the button to a form view, a list view, or a Kanban view, depending on where you want it to be displayed.

After making these changes, the button will be displayed in the user interface, and clicking it will trigger the specified method. In this example, clicking the button will call the "set_field_value" method, which will set the value of the "field_name" field to "New Value".

This feature can be useful if you need to perform custom logic when a user clicks a button, such as updating fields, sending emails, or triggering external actions. By linking the button to a custom method in your model, you can easily extend the functionality of your Odoo application.

odoo videos odoo development odoo tutorial



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