Skip to Content
Menu
This question has been flagged
2 Replies
9820 Views

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

Avatar
Discard
Best Answer

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.

Avatar
Discard
Best Answer

You should return the value as follows:

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

Hope this helps !!

Avatar
Discard
Author

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

Author

"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