콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
2484 화면

Hello, 

I need to run python code when opening a view 

example : when i open invoice form, i need that an account.move method to be run automatically

Is there a way for that? May be a specific decorator for the method ?

아바타
취소
베스트 답변

Hi,

Try create a boolean field on the model and mention the compute function on that field
then write a compute function without the depends decorator and include the boolean field on form view

for eg:

is_check = fields.Boolean("Check", compute="compute_is_check")

then inherit form view of account.move add the field to view. you can also make that field invisible

define compute method

def compute_is_check(self):
for record in self:
record.is_check = True
record.action_post()

Then the action_post will work when open form view.

Regards

아바타
취소