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

NameError: global name is not defined

By
Lakay lakay
on 9/23/14, 3:53 AM 3,947 views

class si(osv.osv):
        _name='si'
        _columns ={

'street':fields.char('Street',size=100,required=True),

}

  def btnSet(self,cr,uid,ids,values,context=None):

 

self.pool.get('res.partner').write(cr,uid,ids,{'street2':street},context=context)

return True

 

si()

 

why i got this error? 

self.pool.get('res.partner').write(cr,uid,ids,{'street2':street},context=context) NameError: global name 'street' is not defined

 

I just want to transfer the value from my 'street' field to the res_partner's street2 field. 

 

 

0

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3918
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 9/23/14, 4:02 AM

Try this

def btnSet(self,cr,uid,ids,values,context=None):
     current_obj = self.browse(cr, uid, ids, context)
     street = current_obj.street
# we have to get the street value from the current record
     self.pool.get('res.partner').write(cr,uid,ids,{'street2':street},context=context)
return True

it works atchuthan thanks! can i ask question, whats the purpose of context parameter why is it not context=None or context=context..

Lakay lakay
on 9/23/14, 4:19 AM

it works atchuthan thanks! can i ask question, whats the purpose of context parameter why is it not context=None or context=context..

Lakay lakay
on 9/23/14, 4:19 AM

oh isee i now get it thanks atchuthan!

Lakay lakay
on 9/23/14, 4:24 AM

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: 9/23/14, 3:53 AM
Seen: 3947 times
Last updated: 3/16/15, 8:10 AM