跳至内容
菜单
此问题已终结
2 回复
12102 查看

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

形象
丢弃
最佳答案

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>

形象
丢弃
编写者

Thank you Sajin

编写者 最佳答案

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

 

形象
丢弃