Skip to Content
Menu
This question has been flagged

I have a function which checks the dates and then calculates the arrivals and departures using the data. but there are two problems, the first one is that I need to do this an automatic function so the user doesn't need to click 'update' and I tried to solve this by using this code below:

@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False,
submenu=False):
res = super(HotelReservation, self).fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar,
submenu=submenu)

self.expected_arrivals_departures()

return res

the only problem with this is that it runs 5 times when I need only 1 time to run my function.


Can someone please help me? 

Avatar
Discard
Best Answer

Hi,

The field_view_get function is the function responsible to the render/parse the view and create the view architecture which has to be displayed to the user.  It is executed when you refresh the screen and load a model.

Are you sure about your function has to be called from here itself ? If not, let me know what exactly you need to do or on what condition the expected_arrivals_departures function has to be triggered ?


If it has to be triggered in particular time interval, you can use scheduled actions.

Thanks

Avatar
Discard
Author

i wanted the function to be run automatically when the model loads up so the data will be updated when shown but I think I will
Implement a “onchange” api. Thank you!

hiii,

How can i load the sale.order with compute function when i try with field_view_get it shows loading how can i load the sale order view without loading issue

Related Posts Replies Views Activity
3
Dec 22
2629
2
Apr 20
3558
1
Apr 20
2413
2
Sep 19
7205
2
Jun 19
4492