Skip to Content
Menu
This question has been flagged

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
Discard

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

Best Answer

Hello ,

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

Avatar
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
0
Jan 17
6909
1
Jul 25
1807
0
May 23
1215
5
Dec 23
18548
1
Feb 21
4792