Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
13374 Представления


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

Related Posts Ответы Просмотры Активность
2
сент. 23
4623
2
сент. 22
4368
1
июн. 22
3226
1
июл. 20
9548
1
дек. 19
5263