Odoo Help

0

help orm searchand read output

By
Lakay lakay
on 9/22/14, 11:30 PM 847 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--
3218
| 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

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

2 follower(s)

Stats

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