Odoo Help


get value from self object

Ajeng Shilvie
on 1/7/15, 12:10 AM 1,644 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 : {



it not work at all..

Anil R. Kesariya
On 1/7/15, 1:45 AM

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.




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

Ajeng Shilvie
on 1/7/15, 12:29 AM

"list object has no attribute get"

Ajeng Shilvie
on 1/7/15, 12:31 AM

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.

Emipro Technologies Pvt. Ltd.
on 1/7/15, 12:39 AM

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

Emipro Technologies Pvt. Ltd.
on 1/7/15, 1:43 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/7/15, 12:10 AM
Seen: 1644 times
Last updated: 3/16/15, 8:10 AM