Odoo Help

0

NameError: global name is not defined

By
Lakay lakay
on 9/23/14, 3:53 AM 4,374 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--
Atchuthan - Technical Consultant, Sodexis Inc
http://www.sodexis.com/
3947
| 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
0
Najlae
On 1/4/17, 5:57 AM

hi atchutan i try this 

def _get_tot(self,cr,ids,values,context):

current_obj = self.browse(cr, uid, ids, context)

idstate = current_obj.id

cr.execute("SELECT sum(amount) FROM account_bank_statement_line WHERE statement_id ="+str(idstate)+"")

return cr.fetchall()


i get this error : _get_tot() takes exactly 5 arguments (4 given) 

can u help 

Hi Najlae, please check your method you missed uid at method definition.

it should be like : def _get_tot(self,cr,uid,ids,values,context):

Eventhough, the method you mentioned above does not looks fine,what is your actual requirement, better to use odoo ORM method instead of using postgres queries.

Raaj Mishra
on 1/4/17, 6:06 AM

hi Raaj actually i work on odoo 8 .. in acount.bank.satement.line i add new column name's(Montant crédit 'like amount field') i wanna to get the sum without using <field name="x" sum="x"/> , because i will use the sum to calculate the diffrence .. u can check this link : http://stackoverflow.com/questions/41368634/get-sum-of-the-column-in-odoo8/41373263?noredirect=1#comment70096973_41373263

Najlae
on 1/4/17, 6:23 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 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.

Register

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)

Stats

Asked: 9/23/14, 3:53 AM
Seen: 4374 times
Last updated: 1/4/17, 5:57 AM