QWeb-based PDF reports
When communicating with the outside world, it is often necessary to produce a PDF document from a record in the database. Odoo uses the same templating language as the one used for form views, QWeb.
In this recipe, we will create a QWeb report to print the book currently borrowed by a member of our library example. This recipe will reuse the models presented in the Email templates recipe from this chapter.
Getting ready
In case you haven't done it till now, install wkhtmltopdf
as described in Chapter 1, Installing the Odoo Development Environment, otherwise you won't get shiny PDFs as a result of your efforts.
Also, double-check that the configuration parameter—web.base.url
(or alternatively, report.url
)—is a URL accessible from your Odoo instance, otherwise report generation takes ages and the result looks funny.
How to do it...
- Define a view for your report in
reports/book_loan_templates.xml
:
<?xml version="1.0" encoding="utf-8"?> <odoo> <template id="my_module...