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

i make custom module refer to res.partner , i make duplicate address with boolean field called "same". So when the boolean field checked my duplicate address will automatically filled base on address in the header of the form. I cannot get value from address .

i use this code

def on_change_address(self,cr,uid,vals,same):

    a = vals.get("street")

   if same :

          return : {

                       'my_new_street','=',a

                       }

it not work at all..

아바타
취소
베스트 답변

Hello Ajeng Shilvie ,

Here you go! Updated your method.

#your argument list was incorrect as 4th arugmnet you will get ids not dictionary you cannot use get method on list.

def on_change_address(self, cr, uid, ids, same, context=None):

   # a = vals.get("street")  Removed this line.

   #body of your code here you can get new address by browse your record using ids and reutrn that value from your dictionary with value key.

   if same :

          return : {

                      'value':{ 'my_new_street':'Your new address'}

                       }

#Note : when you use use onchange method you need to return your updated dictionary with latest data as value of value(key).  eg. {'value':{this dictionary will having the udpated information of your fields.}}.

Hope this will helps you.

Regards,

Anil.

아바타
취소
베스트 답변

You should return the value as follows:

return {'value':{'my_new_street':<<your value>>,'my_new_city':<<your_new_city'}}

Hope this helps !!

아바타
취소
작성자

its not working , i cannot use get on vals it said it have to be int not str

작성자

"list object has no attribute get"

in you on change method you should pass individual values of street, city, etc. This is not create or update method where you can get the vals. Pass the values individually. Here 'vals' is not a dictionary. Look into other examples of 'on_change' methods.

share your view, so that we can get to know what have you passed from the xml file for onchange method