Qweb Reporting Engine | To day you will learn how to create custom reports in Odoo using QWEB reporting engine. In this post we will learn how to create simple custom reports and its template using QWEB.
What is QWEB
Qweb is a reporting engine or template engine used by Odoo. By using this (QWEB) we can create reports in odoo. It uses XML to create design of reports as per your need. We can also say that QWEB is XML based reporting engine for OpenERP/Odoo.
Read More: How to Add Page Number in QWEB Report
Models.py
Description
Here we describe important lines, In line no 1 we declare a class named "example_report" and here we use "AbstractModel", for creating our reports.
Read More: Add Custom Header and Footer in QWEB Reports
In line no 2 we declare the name of our report (Note: Here the important things is the name of the report should be same as the name of "template_id" which is created in xml file of the report.) and In line no 14 we render our "Data" to xml files.
XML
Description
Here the name of template id (report_my_custom_report) is same as the name of report (Line no 2 in Model.py file).
The screen shot of above report is given below:
4 Comments
How do I call the report?
ReplyDeleteYes good question :) you can call that report on button click. I will share this code on Monday. Thanks
Delete@api.multi
Deletedef view_report_button(self):
#your logic goes here for data
return {
'type': 'ir.actions.report.xml',
'report_name': 'your_module_name.report_you_report_template_id',
'report_type':"qweb-pdf",
'data':{'key1':value1,'key2':value2},
}
Above is the code for button to open report.
does this works in odoo11? I heard "report" has been eliminated from odoo 11
Delete