Skip to Content
Menu
This question has been flagged
1 Reply
4835 Views

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?

Avatar
Discard
Best Answer

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

Avatar
Discard