Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
12878 Lượt xem


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 



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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 

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Ok, let try I hope it works for you.

Tác giả

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

Tác giả

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

@api.multi

def _target_achieve(self):

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

not run :(

Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 23
4079
2
thg 9 22
3669
1
thg 6 22
2810
1
thg 7 20
9056
1
thg 12 19
4852