If useful or necessary, it is possible to specify a Paper Format for the report report.
Report templates will always provide the following variables:
a reference to
timefrom the Python standard library
res.userrecord for the user printing the report
record for the current
the current website object, if any (this item can be present but
the base url for the webserver
Minimal viable template
A minimal template would look like:
external_layout will add the default header and footer on your report. The PDF body will be the content inside the
<div class="page">. The template’s
id must be the name specified in the report declaration; for example
account.report_invoice for the above report. Since this is a QWeb template, you can access all the fields of the
docs objects received by the template.
By default, the rendering context will also expose the following items:
records for the current report
list of ids for the
model for the
If you wish to access other records/models in the template, you will need a custom report, however in that case you will have to provide the items above if you need them.
If you wish to translate reports (to the language of a partner, for example), you need to define two templates:
The main report template
The translatable document
You can then call the translatable document from your main template with the attribute
t-lang set to a language code (for example
en_US) or to a record field. You will also need to re-browse the related records with the proper context if you use fields that are translatable (like country names, sales conditions, etc.)
For example, let’s look at the Sale Order report from the Sale module:
The main template calls the translatable template with
doc.partner_id.lang as a
t-lang parameter, so it will be rendered in the language of the partner. This way, each Sale Order will be printed in the language of the corresponding customer. If you wish to translate only the body of the document, but keep the header and footer in a default language, you could call the report’s external layout this way:
Barcodes are images returned by a controller and can easily be embedded in reports thanks to the QWeb syntax (e.g. see attributes):
More parameters can be passed as a query string
Twitter Bootstrap and FontAwesome classes can be used in your report template
Local CSS can be put directly in the template
Global CSS can be inserted in the main report layout by inheriting its template and inserting your CSS:
If it appears that your PDF report is missing the styles, please check these instructions.
Paper formats are records of
report.paperformat and can contain the following attributes:
only useful as a mnemonic/description of the report when looking for one in a list of some sort
a small description of your format
either a predefined format (A0 to A9, B0 to B10, Legal, Letter, Tabloid,…) or
custom; A4 by default. You cannot use a non-custom format if you define the page dimensions.
output DPI; 90 by default
margin sizes in mm
page dimensions in mm
Landscape or Portrait
boolean to display a header line
header spacing in mm
By default, the reporting system builds rendering values based on the target model specified through the
However, it will first look for a model named
report.module.report_name and call that model’s
_get_report_values(doc_ids, data) in order to prepare the rendering data for the template.
This can be used to include arbitrary items to use or display while rendering the template, such as data from additional models:
If you want to use custom fonts you will need to add your custom font and the related less/CSS to the
web.reports_assets_common assets bundle. Adding your custom font(s) to
web.assets_backend will not make your font available in QWeb reports.
You will need to define your
@font-face within this less file, even if you’ve used in another assets bundle (other than
After you’ve added the less into your assets bundle you can use the classes - in this example
h1-title-big - in your custom QWeb report.
Reports are web pages
Reports are dynamically generated by the report module and can be accessed directly via URL:
For example, you can access a Sale Order report in html mode by going to http://<server-address>/report/html/sale.report_saleorder/38
Or you can access the pdf version at http://<server-address>/report/pdf/sale.report_saleorder/38
it does not matter what timezone the
datetimeobject is actually in (including no timezone), its timezone will unconditionally be set to UTC before being adjusted to the user’s