Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3211 มุมมอง

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']})

คำตอบที่ดีที่สุด

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

updated answer

ผู้เขียน

oh thanks Prakash! this time it works!