Odoo Help


execute SQL in Qweb report

Abdullah Sofan
on 12/12/14, 12:44 PM 3,528 views

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

Sajin Aziz
On 12/14/14, 12:06 AM

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):
        _res = self._cr.dictfetchall()
        return _res


     <t t-foreach="docs" t-as="o">
                    <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>

Thank you Sajin

Abdullah Sofan
on 12/14/14, 12:26 AM
Abdullah Sofan
On 12/13/14, 2:17 PM

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


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 12/12/14, 12:44 PM
Seen: 3528 times
Last updated: 3/16/15, 8:10 AM