Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
7249 Visualizzazioni

Hello all,

when i search records using low sql   

request.env.cr.execute(sql)

request.env.cr.dictfetchall()

then i received ResultSet as list  it is not useful in qweb template to get some additional fields like image..

so how to convert list to object or any solution to use list as object in qweb template. Can anyone help me.


Thanks in advance..




Avatar
Abbandona

first, you need to convert in the record set from the list of ids

like : request.env[here is related model].browse(list of ids )

after that, you can use an object(record) in Qweb template

Risposta migliore

Hello ,

If you get list of id than you can browse id and get related value from this.

Avatar
Abbandona
Risposta migliore

Hello Haresh,

I don't know why you are using sql query to get result.

but there is solution for this, your getting out put like this [{'id':90},{'id':99}]
then do one think

your orm object example sale.order

sale_obj = self.env['sale.order']

result = request.env.cr.dictfetchall()

if result:
    for single_dict in result:
        sale_obj += self.env['sale.order'].browse(single_dict['id'])

 


Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
gen 17
6913
1
lug 25
1812
0
mag 23
1219
5
dic 23
18554
1
feb 21
4799