コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
13326 ビュー


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 



アバター
破棄
最善の回答

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 

アバター
破棄
著作者

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

Ok, let try I hope it works for you.

著作者

@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 :(

著作者

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

@api.multi

def _target_achieve(self):

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

not run :(

著作者

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

関連投稿 返信 ビュー 活動
2
9月 23
4615
2
9月 22
4354
1
6月 22
3224
1
7月 20
9541
1
12月 19
5254