Odoo Help

Welcome!

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

0

AttributeError: 'NoneType' object has no attribute 'address_get

By
Emna Ragheb
on 3/21/14, 8:11 AM 1,073 views

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, [partner.id],['delivery', 'invoice', 'contact', 'default', 'other'])

val= {

'client_address_id':addr ['default'],

'delivery_addres_id':addr['delivery']

}

return {'value':val}

 

(*.xml):

<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, [partner.id],['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, 

Thank you !! 

it works now but in the field 'client_address_id' I got the name of the partner not address

what should I do to obtaint that result ??


------------------------------------------------------------------------------------

Cordialement ,

Amna RAGHEB 

Ingénieur en Informatique Industrielle et Automatique 

(+216)21 99 85 16



2015-02-15 22:46 GMT+01:00 Mariusz Mizgier <mariusz.mizgier@currenda.pl>:

A new answer for AttributeError: 'NoneType' object has no attribute 'address_get has been posted. Click here to access the post.

--
Mariusz Mizgier
Sent by Odoo S.A. using Odoo about Forum Post AttributeError: 'NoneType' object has no attribute 'address_get

Emna Ragheb
on 2/15/15, 4:59 PM
0
Mariusz Mizgier
On 2/15/15, 4:46 PM

You have a typo in res_partner - you should be using res.partner instead in line starting with addr.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/21/14, 8:11 AM
Seen: 1073 times
Last updated: 3/16/15, 8:10 AM