Odoo Report Qweb (Part 1)

Installation and Quick Creation

Binh Nguyen Xuan

            Odoo Qweb Report is my nightmare when I was assigned report tasks in my old company. Nobody knows about it clearly. I have to research by myself base on Odoo native modules and build reports by copy paste :( That is a long road, you do not know where to start, how that module works.

            That is reason why I want to write this tutorials to clarify everything about Odoo Qweb Report technical to you.

            This is the first tutorials, in Odoo Qweb Report Series.


            Requirement: WkHtmlToPdf

            Using: 0.12.1 on Ubuntu 14.04

            Create a new install.sh file and executing it.

            echo -e "\n---- Install WkHtmlToPdf 0.12.1 ----"
            sudo wget -P Downloads http://download.gna.org/wkhtmltopdf/0.12/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb
            cd Downloadssudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb
            cd /usr/local/bin
            sudo cp wkhtmltoimage /usr/bin/wkhtmltoimage
            sudo cp wkhtmltopdf /usr/bin/wkhtmltopdf
            echo -e "Wkhtmltopdf is installed!"

            Getting the newest version, you can visit: http://wkhtmltopdf.org/downloads.html

            Quick Creation

            Step 1: Creating a report template

            Follow the OCA directories, you should create a new folder report and add new file named "product_template_report_templates.xml" (please forget the .settings folder :D)

            Create a new report template:

            <template id="odoo_qweb_report_sample.product_template_report_template">
                <t t-call="report.html_container">
                    <t t-foreach="docs" t-as="o">
                        <div class="page">
                            <t t-esc="o.name" />

            docslist products which selected in tree view or selected product in form view
            t-as="o": O present to a record (browse record)

            Step 2: Declaring the Action Report XML

            <report id="odoo_qweb_report_sample.product_template_report"
                    string="Product Report"
            • name (mandatory): only useful as a mnemonic/description of the report when looking for one in a list of some sort

            • model (mandatory): the model your report will be about

            • report_type (mandatory): either qweb-pdf for PDF reports or qweb-html for HTML

            • groups: many2many field to the groups allowed to view/use the current report

            OK, let’s insert the new xml file into the __openerp__.py and upgrade the  module.

            Now in tree view, when you select one or more products, button Print will be appear.

            In the form view, you could see the print button also.

            That is the simplest to create a Qweb Report in Odoo. The sample code available on my github repository, branch 1.0.

            Let's continue with the next tuts to break the Odoo report secret.