hi,
i need to trigger a custom event on selection of a value in a many2one field on form view, is there any way to do it?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
hi,
i need to trigger a custom event on selection of a value in a many2one field on form view, is there any way to do it?
Hi,
you should inherit and override the widget in your custom module. The many2one widget is defined in web/static/src/js/fields/relational_fields.js.
In the widget 'FieldMany2one' you can see the custom event 'field_changed' and the related method '_onFieldChanged'. So, what is needed, is to trigger your event in the latter method.
For more info about Odoo fields' widgets (and javascript in general) have a look at the documentation - https://www.odoo.com/documentation/master/reference/javascript_reference.html#widgets
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up