Reports are an invaluable feature for business apps. The built-in QWeb reports engine, available since version 8.0, is the default report engine. Reports are designed using QWeb templates to produce HTML documents that can then be converted to PDF form.
The Odoo built-in report engines have undergone significant changes. Before version 7.0 reports were based on the ReportLab library and used a specific markup syntax, RML. In version 7.0, the Webkit report engine was included in the core, allowing for reports to be designed using regular HTML instead. Finally, in version 8.0 this concept was taken a little further, and the QWeb templates became the main concept behind the built-in reporting engine.
This means we can conveniently leverage what we have learned about QWeb and apply it to create business reports. In this chapter, we will be adding a report to our To Do app, and will review the most important techniques to use with QWeb reports , including report computations, such as totals, translation and print paper formats.
But before we start, we must make sure that we have installed the recommended version of the utility used to convert HTML into PDF documents.
To correctly generate reports, the recommended version of the wkhtmltopdf
library needs to be installed. Its name stands for Webkit HTML to PDF. Odoo uses it to convert a rendered HTML page into a PDF document.
Older versions of the wkhtmltopdf
library are known to have issues, such as not printing page headers and footers, so we need to be picky about the version to use. For version 9.0, at the time of writing the recommended version is 0.12.1. Unfortunately, the odds are that the packaged version provided for your host system, Debian/Ubuntu or other, is not adequate. So we should download and install the package recommended for our OS and CPU architecture. The download links can be found at http://wkhtmltopdf.orgor http://download.gna.org/wkhtmltopdf
.
We should first make sure that we don't have an incorrect version already installed in our system:
$ wkhtmltopdf --version
If the above reports a version other than the one we want, we should uninstall it. On a Debian/Ubuntu system we can use:
$ sudo apt-get remove --purge wkhtmltopdf
Next we need to download the appropriate package for our system and install it. Check the correct file name at http://download.gna.org/wkhtmltopdf/0.12/0.12.1 . For Ubuntu 14.04 LTS (Trusty) 64 bits, the download command would be like this:
$ wget http://download.gna.org/wkhtmltopdf/0.12/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb -O /tmp/wkhtml.deb
Next we should install it. Installing a local deb
file does not automatically install dependencies, so a second step will be needed to do that and complete the installation:
$ sudo dpkg -i wkhtml.deb $ sudo apt-get -f install
Now we can check if wkhtmltopdf
library is correctly installed, and confirm it's version number is the one we want:
$ wkhtmltopdf --version wkhtmltopdf 0.12.1 (with patched qt)
After this, the Odoo server start sequence won't display the You need Wkhtmltopdf to print a pdf version of the report's info message.