Trigger Odoo fields_view_get dynamically after all records being loaded and fields_view_get function called Trigger Odoo fields_view_get dynamically after all records being loaded and fields_view_get function called python python

Trigger Odoo fields_view_get dynamically after all records being loaded and fields_view_get function called


The fields_view_get gets called from the load_views at https://github.com/odoo/odoo/blob/10.0/odoo/models.py#L1334 and the load_views gets called by the web client's view manager at https://github.com/odoo/odoo/blob/10.0/addons/web/static/src/js/view_manager.js#L130

Now, see in the view_manager.js where is the load_view called from and when. We can see that it is called at https://github.com/odoo/odoo/blob/10.0/addons/web/static/src/js/view_manager.js#L182 which is the call that interests us.

The willStart function if you see on the widget.js is called when the widget is attached on the DOM it manages. The attachment happens only once when the dom is loaded.

So, to recap, the fields_view_get is run once when the page is loaded and if you want to call it again you are going to need to do it from the js/web client side of things by calling the load_views javascript function.

But usually in Odoo, try to avoid web client extensions if possible. If you want to make changes on the current view based on actions of the user you can use onchange or any other backend hook.