Odoo Help

Welcome!

This community 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.

3

execute SQL in Qweb report

By
Abdullah Sofan
on 12/12/14, 12:44 PM 1,942 views

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

2
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):
        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

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

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

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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