- 上传者: Administrator
- 上传时间:2025年04月28日 08时52分36秒
* How to create Qweb-based pdf reports ** *** Odoo plays a vital role in making a business efficient. The analysis of various areas is important in ......
How to create Qweb-based pdf reports
Odoo plays a vital role in making a business efficient. The analysis of various areas is important in terms of the organization's growth in the ERP system. This is where we use reporting.
Qweb is a reporting engine that generates PDF reports. It handles data easily using XML. The Qweb template engine usually converts XLM to HTML. And PDF rendering is done by wkhtmltopdf. Reports are generated using report action and report templates for the action to use.
Report Action:
Report actions are triggered when reports need to be generated. The report action is written inside the XML file created in the report file of the module. The report action can be written like this;
<record id="action_report_vehicle_order" model="ir.actions.report">
<field name="name">Vehicle Order</field>
<field name="model">vehicle.report</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">vehicle.report_vehicle_order</field>
<field name="report_file">vehicle.report_vehicle_order</field>
<field name="print_report_name">'Vehicle Report - %s' % (object.name))</field>
<field name="binding_model_id" ref="model_vehcicle_report"/>
<field name="binding_type">report</field>
</record>
The fields of the report action are mentioned below in detail;
● name: Name of the report to be specified.
● model : It’s a mandatory field from which the records will be retrieved into the report.
● report_type: It specifies the type of the report, such as ‘qweb-text,’ ‘qweb-html,’ ‘qweb-pdf’. This used mainly two values qweb-pdf and qweb-html. The default value is qweb-pdf.
● report_name: Here, it specifies the external id of the report template.
● print_report_name: It specifies the report file name, and here the python expressions also can be used.
● binding_model_id: If the reports need to be printed from the Print action, then the required model id can be specified here.
Report Templates:
The structure of the report species in the report templates. It’s an XML file created inside the report file of the module. Inside the template, HTML is used to design the report as required.
<template id="report_vehicle_order">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="web.external_layout">
<div class="page">
<h2>Sample Report</h2>
<p>span t-field="o.name"/></p>
</div>
</t>
</t>
</t>
</template>
The id of the template is external if that is mentioned in the report action. By calling the external_layout, the report will get the default layout of Odoo. The template always contains the variables like time, user, res_company, website, web_base_url, and context_timestamp.
<field name="name">Vehicle Order</field>
<field name="model">vehicle.report</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">vehicle.report_vehicle_order</field>
<field name="report_file">vehicle.report_vehicle_order</field>
<field name="print_report_name">'Vehicle Report - %s' % (object.name))</field>
<field name="binding_model_id" ref="model_vehcicle_report"/>
<field name="binding_type">report</field>
</record>
The fields of the report action are mentioned below in detail;
● name: Name of the report to be specified.
● model : It’s a mandatory field from which the records will be retrieved into the report.
● report_type: It specifies the type of the report, such as ‘qweb-text,’ ‘qweb-html,’ ‘qweb-pdf’. This used mainly two values qweb-pdf and qweb-html. The default value is qweb-pdf.
● report_name: Here, it specifies the external id of the report template.
● print_report_name: It specifies the report file name, and here the python expressions also can be used.
● binding_model_id: If the reports need to be printed from the Print action, then the required model id can be specified here.
Report Templates:
The structure of the report species in the report templates. It’s an XML file created inside the report file of the module. Inside the template, HTML is used to design the report as required.
<template id="report_vehicle_order">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="web.external_layout">
<div class="page">
<h2>Sample Report</h2>
<p>span t-field="o.name"/></p>
</div>
</t>
</t>
</t>
</template>
The id of the template is external if that is mentioned in the report action. By calling the external_layout, the report will get the default layout of Odoo. The template always contains the variables like time, user, res_company, website, web_base_url, and context_timestamp.
本文章从网上收集,如有侵权请联系tderp@tderp.com删除- 微信扫一扫,一分也是爱:
-
服务原则及地区范围
宜兴通达网络科技有限公司,地处中国宜兴环科园内,是一家高新技术企业。公司在企业网络维护和企业信息化建设与咨询方面,有10多年经验。
我公司愿与客户一道,力求彻底解决客户问题!
我们不是在给企业提供“头痛医头、脚痛医脚”的暂时解决方案,而是在部署根本性安全与稳定服务!!
我们愿携手客户,建立企业IT规划;杜绝随意安装系统、软件等操作;力求共同维护有序、安全、稳定的网络办公环境!!!
IT服务,服务是根本,客户是上帝;我们提供快速响应、快速上门、快速排查,提供优质高效的服务!!!!
通达科技提供全国范围内的服务,服务形式包括远程协助、电话咨询、电子邮件咨询、传真咨询、问答平台的问题解决等。
宜兴地区提供上门服务:
- 市区服务:宜城街道、城北街道(屺亭街道)、新街街道、新庄街道、环科园、渚桥开发区
- 市郊服务:张渚镇、西渚镇、太华镇、徐舍镇、官林镇、杨巷镇、新建镇、和桥镇、高塍镇、万石镇、周铁镇、芳桥镇、丁蜀镇、湖父镇。