Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
10315 Widoki

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..

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Najlepsza odpowiedź

You should return the value as follows:

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

Hope this helps !!

Awatar
Odrzuć
Autor

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

Autor

"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