This question has been flagged
2 Replies
11224 Views

Is it possible to display a search sql statement output in QWEB report? If yes, can you direct me to an example?

Avatar
Discard
Best Answer

Try this .

write a function in your report model to run sql statement and return the result , so u can pass sql qry from Qweb Report,

 def run_sql(self, qry):
        self._cr.execute(qry)
        _res = self._cr.dictfetchall()
        return _res

 

     <t t-foreach="docs" t-as="o">
                <p>
                    <t t-set="emp_count" t-value="o.run_sql('select COUNT(*) from hr_employee')"/>
                    <t t-set="latest_partner" t-value="o.run_sql('select id, name from res_partner  order by id DESC limit 10')"/>
                    <p > Employee Count: <span t-esc="emp_count" /> </p>
                     <t t-foreach="latest_partner" t-as="part">
                         <p> Customer - <span t-esc="part_index"/>:  <span t-esc="part"/>  </p>
                     </t>
                 </p>
     </t>

Avatar
Discard
Author

Thank you Sajin

Author Best Answer

I am struggling on this for days. Can someone help?

 

Avatar
Discard