How To Generate XLSX Report Using Controller in Odoo 18
Overview
The ability to generate dynamic reports in Excel (XLSX) format is a crucial feature in enterprise resource planning (ERP) systems like Odoo. These reports offer users the flexibility to analyze, share, and archive structured data in a portable and editable format.
This document outlines two possible solutions for creating XLSX reports in Odoo without using the report_xlsx module. For that we utilize Odoo's HTTP controller to achieve a modular and scalable solution.
https://odoo-community.org/shop/base-report-xlsx-2202
Using Controller and Transient Model
- Add report content in wizard model
- Add new transient model 'common.xlsx.out' with filedata, filename fields.
- Add Common controller to download file
zb_outstanding_report / views /outstanding_report_wiz_view.xml
zb_outstanding_report / wizard /outstanding_report_wiz.py
zb_outstanding_report /wizard /common_xlsx_out.py
zb_outstanding_report /controllers / main.py
Clicking on the Outstanding Statement menu will display the pop-up defined in the wizard
The XLSX report will be generated upon clicking the XLSX button
Conclusion
The implementation of XLSX report generation in Odoo provides developers with flexible and efficient solutions to meet various reporting needs. Whether choosing the wizard-based approach with a common controller or the direct controller approach each method offers distinct advantages that can be leveraged based on specific requirements. Common controller provides better modularity and maintainability for complex reports, while direct controller offers a streamlined solution for simpler reporting needs.
If you are looking for an ERP implementation partner with diverse industry experience feel free to contact us. We have proven track record of successful implementations across various sectors including Odoo for Manufacturing, Odoo for Trading, Odoo for FMCG, Odoo for Oil & Gas, Odoo for Diary, Odoo for Pharma, Odoo for Cosmetic Clinic, Odoo for Contracting Companies, Odoo for HVAC, Odoo for Logistics, Odoo for Automobile, Odoo for Laundry, Odoo for Field Service, Odoo for E-Commerce & many more