How to Trigger Functions on Button Click in Odoo 16 | Odoo 16 Development Tutorial – CBMS Odoo ERP

How to Trigger Functions on Button Click in Odoo 16 | Odoo 16 Development Tutorial – CBMS Odoo ERP

2
1 minute, 29 seconds Read

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.
#odoodevelopment #odootutorials

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 recordset 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. #odoo16

Connect With Us:
—————————————
➡️ Website:
➡️ Email: info@cybrosys.com
➡️ Twitter:
➡️ LinkedIn:
➡️ Facebook:
➡️ Instagram:
➡️ Pinterest:

#Trigger #Functions #Button #Click #Odoo #Odoo #Development #Tutorial

Similar Posts

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *