Odoo Report Qweb (Part 1)
Installation and Quick Creation
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.
Installation
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.debcd Downloadssudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.debcd /usr/local/binsudo cp wkhtmltoimage /usr/bin/wkhtmltoimagesudo cp wkhtmltopdf /usr/bin/wkhtmltopdfecho -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" /></div></t></t></template>
Step 2: Declaring the Action Report XML
<report id="odoo_qweb_report_sample.product_template_report"name="odoo_qweb_report_sample.product_template_report_template"file="odoo_qweb_report_sample.product_template_report_template"model="product.template"report_type="qweb-pdf"string="Product Report"menu="True"/>
id: the generated record's external id
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
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.