ZestyBeanz Technologies Pvt Ltd 4th Floor, Nila, Technopark Thiruvananthapuram,
India – 695581
Phone: +91 471 4063254
Fax : +91 471 2700171


ZestyBeanz Technologies Pvt Ltd
61/3236, Manikkath Cross Road
Ravipuram, Kochi, India - 682016
Phone: +91 484 4063254


Zesty Labs
Office # 2003, Millennium Plaza Building
Sheikh Zayed Rd, Dubai, UAE
Phone: +971 4333 2222​
Mobile: +971-52-7553466


ZestyBeanz Technologies GmbH
Reuterstraße 1
90408 Nürnberg
Fon: +49 911 4801 444
Fax: +49 911 4801 445

QWeb Report in Odoo 8

Contact Form

anju's picture

QWeb Report in Odoo 8

QWeb is the primary templating engine used by Odoo. It is an XML templating engine and used mostly to generate HTML fragments and pages.

It's implemented fully in javascript and rendered in the browser.

Each template file (XML files) contains multiple templates, where template engine usually have a 1:1 mapping between template files and templates.

The rationale behind using QWeb instead of a more popular template syntax is that its extension mechanism is very similar to the openerp view inheritance mechanism. Like openerp views a QWeb template is an xml tree and therefore xpath or dom manipulations are easy to performs on it.

1. Creating a new XML file
The first step to create your own new report is to make a new XML file. This file should be placed under yourModuleName/views and you can name it as you wish. In this file you will define the template id’s and names, which will later on be used by your Odoo to find the correct report.

The minimal code looks like this:

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. Calling external_layout will add the default header and footer on your report. The PDF body will be the content inside the <div class="page">.

There are some specific variables accessible in reports, mainly:
records for the current report

list of ids for the docs records

model for the docs records

a reference to time from the Python standard library

a function to translate a part of a report.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 translate_doc from your main template to obtain the translated document.

 It must be used as follow:

The name of the template id (from the first record) should be the same as the name for the t-raw that handles translations. In the t-raw you need to add the module name before this name with a dot. The main template calls translate_doc with partner_id.lang as a parameter, which means it uses a custom report model to access a res.partner record.

res.user record for the user printing the report

record for the current user‘s company

2.Add the report to the XML file responsible for reports
Every module has a file that makes a reference to every single report in the module. This is done by a item, which can be found in the XML file.
This file always has the same name structure. It starts with the name of your module, an underscore and then report.xml. Its found in the first level of the directory of your module.
The filename is always yourModuleName_report.xml. Now open up this file and you will see a tag for every report that exists in this module.
The next step for us is to add a new tag for our own report. The code looks like this:

3.Declare a paper format

Paper formats are records of report.paperformat and can contain the following attributes:

name (mandatory)
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_top, margin_bottom, margin_left, margin_right
margin sizes in mm

page_height, page_width
page dimensions in mm

Landscape or Portrait

boolean to display a header line

header spacing in mm

You have now everything to create reports

  1. A template (ir.ui.view record)
  2. A report record ( record)
  3. And maybe a specific paper format (report.paperformat record)

Parser Class:
To create parser class you need to import report_sxw.rml_parse.
The methods you want to access in report must be updated in localcontext in parser class.
Create another class which which inherits features of osv.AbstractModel and it creates bond between parser class and template engine.
This new class have few parameters and each of the parameters have fixed pattern so must follow it.
_name = ‘report.<module_name>.<report_name>’
_inherit = ‘report.abstract_report’
_template = ‘<module_name>.<report_name>’
_wrapped_report_class = <parser_class_name>

Ikea case study analysis's picture

Hi, this is a nice blog

Hi, this is a nice blog thanks for sharing the informative blog. My assignment help provides the Ikea case study analysis for an assist to student queries. Our writers conduct thorough research to provide you with a flawless sample of Ikea case study analysis. If you get more details Please visit the site through Link.

Sylvester's picture

Could you please elaborate

Could you please elaborate more on the parser class? I need to use fields from different models to generate my report. Will appreciate an example like the one above. Thank you

Michelle Salas's picture

Web report and finance is

Web report and finance is calculated for the improvement of the clues for the candidates. The reporting authority and Myassignmentwriting is amalgamated with the supportive mechanism and all officials of the down. The present element is filled for the range of the concepts for the moves for strange elements. the turn is filled for the programs for the width of the blocks for strange agents.

Samba's picture

Thanks Anju, This Post help

Thanks Anju,
This Post help me allot. I need some more explanation on the pdf report development. I have an issue

. I want to change the pdf report file name to sale.report_sale to "quotation XXXX", here XXXX would be the quotation number. Is it posiible?

Anonymous's picture

def print_report(self,cr,

def print_report(self,cr, uid, ids, context=None):
if context is None:
context = {}
data =, uid, ids)[0]
self_browse = self.browse(cr, uid, ids)

datas = {
'ids': [data.get('id')],
'model': 'sale.order',
'form': data
return {
'type': '',
'report_name': '',
'datas': datas,
'name': 'Quotation ' + self_browse[0].name

Nehemias's picture

Very incomplete guide, not

Very incomplete guide, not helpful. :(

Carmelo Carrillo's picture

Hi, If I modify the


If I modify the account_report.xml for add a new invoice, how I do to view this new record on odoo? Have I restart the odoo server?

Thank you.

Anonymous's picture

Yes. You have to restart and

Yes. You have to restart and upgrade the module.

Anonymous's picture

Yes. You have to restart and

Yes. You have to restart and upgrade the module.

programming assignment help's picture

GotoAssignmenthelp Service is

GotoAssignmenthelp Service is a well-established and prominent name in providing high-quality cheap assignment help online to students since almost a decade. You can trust our academic ghost writers completely to get best quality write-ups including case studies, research proposals, dissertations and theses, and more. It is the best do my matlab assignment service. Students should always keep themselves ready to meet the university requirements in order to achieve good grades, moreover, they prefer attending lengthy classes instead of writing assignments. Students who are not comfortable with writing assignments can avail university java help help at Gotoassignmenthelp Services comparatively low prices.