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

I was wondering how to set field attributes (invisible, readonly, domain, ...) in form via @api.onchange (as it was returning the attributes from the method in v7)?


아바타
취소
베스트 답변

Hi Nedas,

   Right now in onchange no need to return anything(in new api), but there is a case when we want to return some warning, domain or other stuff. So, in this case we can return as old api style like.

--------------------------------------------------

@api.onchange('my_field')

def onchange_my_field(self):

     msg={}

     self.my_other_field = self.my_field #Here just copy whatever come with my_field into my_other_field

     if (self.warning==True):

         msg = { 'title': _('Waning!'), 'message' : 'You have just copy my field into my other field...'

                         }

   return {'warning': msg}

-----------------------------------------------         

same way we can return other stuff.

Hope this will help u as u want...

아바타
취소
관련 게시물 답글 화면 활동
2
12월 23
17673
1
3월 15
6137
3
8월 23
7144
2
5월 16
9080
2
1월 16
5317