Community mailing list archives

Re: AttributeError: 'NoneType' object has no attribute 'address_get'

Serpent Consulting Services Pvt. Ltd., Jay Vora
- 02/15/2015 23:55:48
Ragheb Amna,

Please replace this line:
addr= self.pool.get('res_partner')
addr= self.pool.get('res.partner')

Rest seems right!


On Mon, Feb 16, 2015 at 2:26 AM, Ragheb Amna <> wrote:

Hello Community, 

I was creating a function 'onchange' wich must return the address of the selected partner,

I have this three fields : 

  • 'client_id' : fields.many2one('res.partner', u'Client', change_default=True, required=True),
  • 'client_address_id': fields.many2one('res.partner', u'Adresse du client', readonly=True),
  • 'delivery_address_id': fields.many2one('res.partner', u'Adresse de livraison',readonly=True, help="La distance est calculée à partir de l'adresse de votre entreprise jusqu'à l'adresse de livraison du client. Google Map est utilisé pour calculer la distance."),  

 here is the function (*.py): 

def onchange_partner_id(self, cr, uid, ids, part, context=None):

if not part :

return{'value' :{'client_address_id':False, 'delivery_addres_id':False}}

partner=self.pool.get('res.partner').browse(cr, uid, part, context=context)

addr= self.pool.get('res_partner').address_get(cr, uid, [],['delivery', 'invoice', 'contact', 'default', 'other'])

val= {

'client_address_id':addr ['default'],



return {'value':val}


<field name="client_id"  colspan="2"  on_change="onchange_partner_id(client_id, context)" attrs="{'readonly':[('state', '=', 'done')]}" 

context="{'show_address': 1, 'default_customer': False}"

                                            options='{"always_reload": True, "highlight_first_line": True}'/>

<field name="client_address_id" colspan="2"   attrs="{'readonly':[('state', '=', 'done')]}"/>

<field name="delivery_address_id" colspan="2"   attrs="{'readonly':[('state', '=', 'done')]}"/> 

After choosing the partner I got this error : 

 addr= self.pool.get('res_partner').address_get(cr, uid, [],['delivery', 'invoice', 'contact', 'default', 'other'])
AttributeError: 'NoneType' object has no attribute 'address_get'
The function address_get already exist ( for example they are using it  in the class 'sale_order' to do the same job) , so why it returns that error in the class that i have created? 
Help me please !!
Best resgards, 

Post to:

The Splendid journey of 2 years in Numbers
Jay Vora,
Managing Director,
<img src="" style="color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
Serpent Consulting Services Pvt. Ltd.
Web :
Mobile : 91 - 9879354457
Twitter: jaynvora
Skype: jaynvora
Blog :