QWeb Report in Odoo 8 - Zesty Beanz
QWeb Report in Odoo 8 - Zesty Beanz
QWeb Report in Odoo 8 - Zesty Beanz
PilihBahasa Search
Call Us Free
Contact Form
QWeb Report
in Odoo 8
February 25, 2015
By anju
QWeb is the
primary
templating
engine used by
Odoo. It is an
XML templating
engine and used mostly to generate HTML fragments and pages.
http://www.zbeanztech.com/blog/qweb-report 1/9
18/11/2015 QWeb Report in Odoo 8 | Zesty Beanz
Each template file (XML files) contains multiple templates, where template
engine usually have a 1:1 mapping between template files and templates.
doc_ids
http://www.zbeanztech.com/blog/qweb-report 2/9
18/11/2015 QWeb Report in Odoo 8 | Zesty Beanz
doc_model
model for the docs records
time
a reference to time from the Python standard library
translate_doc
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.
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.
user
res.user record for the user printing the report
res_company
record for the current users company
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:
name (mandatory)
only useful as a mnemonic/description of the report when looking for one
in a list of some sort
description
a small description of your format
format
dpi
output DPI; 90 by default
http://www.zbeanztech.com/blog/qweb-report 4/9
18/11/2015 QWeb Report in Odoo 8 | Zesty Beanz
margin sizes in mm
page_height, page_width
page dimensions in mm
orientation
Landscape or Portrait
header_line
boolean to display a header line
header_spacing
header spacing in mm
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
http://www.zbeanztech.com/blog/qweb-report 5/9
18/11/2015 QWeb Report in Odoo 8 | Zesty Beanz
_template = <module_name>.<report_name>
_wrapped_report_class = <parser_class_name>
Thanks Anju,
This Post help me allot. I need some more explanation on the pdf report
development. I have an issue
https://www.odoo.com/forum/help-1/question/how-can-i-change-report-
file-...
reply
def print_report(self,cr,
http://www.zbeanztech.com/blog/qweb-report 6/9
18/11/2015 QWeb Report in Odoo 8 | Zesty Beanz
datas = {
'ids': [data.get('id')],
'model': 'sale.order',
'form': data
}
return {
'type': 'ir.actions.report.xml',
'report_name': 'sale.order.report',
'datas': datas,
'name': 'Quotation ' + self_browse[0].name
}
reply
reply
Hi,
http://www.zbeanztech.com/blog/qweb-report 7/9
18/11/2015 QWeb Report in Odoo 8 | Zesty Beanz
Thank you.
reply
reply
reply
http://www.zbeanztech.com/blog/qweb-report 8/9
18/11/2015 QWeb Report in Odoo 8 | Zesty Beanz
Talk to u
Live Chat
Email Us
Good Support
http://www.zbeanztech.com/blog/qweb-report 9/9