An ERP system contains many modules for performing various operations to run a business workflow efficiently. Despite this, every organization wants to know its progress, and they have to present the growth to their boards or authorities, which is when reports come in handy. Therefore, Odoo provides various report projections, such as PDF, graphical presentations, pivot tables, etc.
Odoo uses Qweb as a reporting engine or template engine. By using Qweb, we can create reports in Odoo. Reports can be designed using XML as per your requirements. Odoo Qweb Report is also an OpenERP/Odoo XML based reporting engine. It allows us to manipulate data very easily by using XML
In Odoo, to render PDFs from the Qweb templates, we used Wkhtmltopdf. Furthermore, since the templates are defined in HTML format, as we discussed in the previous section, wkhtmltopdf will render the PDF report from Qweb.
Odoo reports are working with report templates and report actions. The report templates are used in report action to identify which template you want to select. Additionally, when a report is printed, a report action is triggered that can either be called from the Print menu or from a Python function. You can also set custom page format and specified in your report action.
Odoo has different kinds of actions for different operations. For example, reports are generated when the report action is triggered. Furthermore, the report action will be recognized by the model ‘ir.actions.report’ used in the record.
You can specify your report action by adding an xml file in your report directory. Here is an example of a report action.
<record id="action_report_fleet_id" model="ir.actions.report"> <field name="name">Fleet ID</field> <field name="model">fleet.fleet</field> <field name="report_type">qweb-pdf</field> <field name="report_name">fleet..report_fleet_id</field> <field name="report_file">fleet.report_fleet_id</field> <field name="print_report_name">Vehicle - %s' % (object.name)</field> <field name="binding_model_id" ref="model_fleet_fleet"/> </record>
Name: Specify the name of the report.
Model: Specify the model name here where you can fetch the data for the report. model is a mandatory field.
report_type: Here, you can specify the report type. Mainly it stores two values, qweb-pdf and qweb-html. The default value of report_type is qweb-pdf.
report_name: Here, you can specify the external_id of the report template and is a mandatory field
print_report_name: You can use python expressions to generate report filenames.
binding_model_id: If you want to print the report from the Print Action button inside a view, you can bind the action with the corresponding model.
paperformat_id: You can specify the paper format external id here. Moreover, if it is not specified, take the default paper format the company will use.
Define Odoo Qweb Report Template
You can create an xml file inside your report directory. By using the HTML, the templates are designed. You can specify the structure of your report inside the <template> tag. By using the <t-call=” ”/> tag, you can call the other templates in your custom reports.
<template id="report_fleet_id"> <t t-call="web.html_container"> <t t-foreach="docs" t-as="o"> <t t-call="web.external_layout"> <div class="page"> <h2>Report title</h2> <p>This object's name is <span t-field="o.name"/></p> </div> </t> </t> </t> </template>
The Id report_fleet_id is the external id which you specify inside your report action. For example, you can specify the header and footer of your report by using <header> and <footer> tags, or you can call an external id by using the <t-call=” ”/> tags.
You can also generate qweb reports from the wizard. Thus in odoo, one can easily create/custom qweb reports.
If you plan a new ERP Software implementation and you have heard about Odoo and got attracted by the Odoo ERP platform, decided to use it but don’t have time, resources, or knowledge to manage this yourself, thereby looking for professional assistance, then you have come to a right place. Bassam Infotech has implemented scores of Odoo ERP all around the world. In addition, we have also developed and delivered our own customized Odoo applications with minimal Odoo implementation cost.