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


Form Preview

(compute/Default auto run if form is not save. my working is on saved form i need method who refresh/update my field value whenever saved form open)

i want to refresh/update my custom fields when user open his saved form ....

Note

default method & compute method auto run only when form is not save...

when form is save default method & compute method run only when depended fields change 

i want to change/update value of my fields when user open saved form.... at that time compute not run until i changed depended fields ....

any tips or trick 

thanks in advance 



Avatar
Discard
Best Answer

Hello,

They Have Two Options :

Option 1:

You can use fields_view_get method. Try below code maybe it helps you

@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False,
submenu=False):
    res = super(Project, self).fields_view_get(
    view_id=view_id, view_type=view_type, toolbar=toolbar,
    submenu=submenu)
    # add here your condition
    return res

Option 2:

You can use the compute method but in your case, this method not depends on any field mean you can use @api.multi in place of @api.depends

Thanks 

Avatar
Discard
Author

wow you really pick my point of pain let me implement ............

Ok, let try I hope it works for you.

Author

@api.model

def fields_view_get(self, view_id=None, view_type='form', toolbar=False,submenu=False):

res = super(SalePromotion, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar,submenu=submenu)

# add here your condition

res['name'] = 'Test'

print("============== Hi I RUN")

return res

not run :(

Author

sales_target_achieve = fields.Float('Sales Target Achieve', compute='_target_achieve', store=True)

@api.multi

def _target_achieve(self):

print("==============I RUN")

not run :(

Author

your second option is working for my case thank you soo much

Related Posts Replies Views Activity
2
Sep 23
2917
2
Sep 22
2570
1
Jun 22
1880
1
Jul 20
8154
1
Dec 19
4147