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

help orm searchand read output

By
Lakay lakay
on 9/22/14, 11:30 PM 733 views

Hi,

I want to display the internal_number from account.invoice in a character field

i have this code

search2=self.pool.get('account.invoice').search(cr,uid,[('internal_number','=','SAJ/2014/0010')],context=context)

                search3=self.pool.get('account.invoice').read(cr,uid,search2,['internal_number'])

                self.write(cr,uid,ids,{'storage':search3[0]})

 

 the expected result was: SAJ/2014/0010    why is it im getting {'internal_number': u'SAJ/2014/0010', 'id': 19}

how will i arrive in my expected result, what will i change? thanks

 

self.write(cr,uid,ids,{'storage':search3[0]['internal_number']})

Ben Bernard
on 9/23/14, 5:07 AM
0

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 9/23/14, 1:09 AM

Read Method Return list of dictionaries

https://doc.odoo.com/6.0/developer/2_5_Objects_Fields_Methods/methods/

http://snippetbucket.com/2013/09/snippetbucket-openerp-orm-methods/

reads =self.pool.get('account.invoice').read(cr,uid,search2,['internal_number'])

for record in reads:

   internalno =  record['internal_number']

self.write(cr,uid,ids,{'storage':internalno})

im getting error with ur code., line 32, in btnSet self.write(cr,uid,ids,{'storage':search3['internal_number']}) TypeError: list indices must be integers, not str

Lakay lakay
on 9/23/14, 1:34 AM

updated answer

Prakash
on 9/23/14, 4:58 AM

oh thanks Prakash! this time it works!

Lakay lakay
on 9/23/14, 10:30 PM

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

2 follower(s)

Stats

Asked: 9/22/14, 11:30 PM
Seen: 733 times
Last updated: 3/16/15, 8:10 AM