Enable Dark Mode!
By: Albin PJ

How to Create an XLSX Report Using report_xlsx Module in Odoo 16

Technical Odoo 16

For effective analysis and comprehension of a business venture's activities, Excel reports play a vital role. These reports serve as a valuable tool for users to understand the various operations and functions within the venture.

Although Odoo does not natively support the generation of XLSX reports from its reporting system, a solution is available through the use of the report_xlsx module. By incorporating this module into your Odoo setup, you can seamlessly create XLSX reports catering to your business needs.

First of all, it requires the report_xlsx module, which you can download using the link below.


Then you want to create a custom module for creating an XLSX report.

The following files are needed (Not mandatory),

How to Create an XLSX Report Using report_xlsx Module in Odoo 16-cybrosys

Python File

Then you need to get all values for your XLSX report. Fetch the values using Python, and Finally, a report action is triggered using the report_action() method of the object's self.env.ref('price_list_report.price_list_report'). 

class PriceListWizard(models.TransientModel):
_name = 'price.list.wizard'
_description = 'Price List Wizard'
report_type = fields.Selection([('brand', 'Brand')], string="Report Type", default="brand")
data = {}
def generate_report(self):
    products = self.env['product.product'].search([])
    lines = []
    for product in products.mapped('product_tmpl_id'):
           product.image_128 if product.image_128 else "",
    self.data['lines'] = lines
    return self.env.ref('price_list_report.price_list_report').report_action(self,data={})

XML File

<?xml version="1.0" encoding="utf-8"?>
       string="Price List Report"
       file="Price List Report"

In your XML file, you can give a unique id, also specify the following fields

1. id - The unique identifier for the report, set to "price_list_report"

2. model - The model associated with the report, set to "price.list.wizard". This indicates that the report is related to the "price.list.wizard" model in the Odoo module.

3. string - The label or name of the report, set to "Price List Report".

4.report_type - The type of report, set to "xlsx". This suggests that the report will be generated in Microsoft Excel format.

5. name - The internal name of the report, set to "price_list_report.price_list_report".

6. file - The file name for the report, set to "Price List Report". This is the name that will be used when generating the report file.

7.attachment_use - Indicates whether the report should be used as an attachment when generating it. In this case, it is set to "False", which means the report will not be attached but likely be displayed or downloaded directly.

Python  File

We can use another Python file to inherit the report_xlsx module. Call generate_xlsx_report and pass the parameters.

class PriceListReport(models.AbstractModel):
_name = 'report.price_list_report.price_list_report'
_inherit = 'report.report_xlsx.abstract'
_description = 'Price List Report'
def GetData(self):
    return self.env['price.list.wizard'].data['lines']
def generate_xlsx_report(self, workbook, data, lines):
    datas = self.GetData()

The PriceListReport class inherits from the report.report_xlsx.abstract class, which is likely a predefined class provided by the Odoo framework.

The generate_xlsx_report method is responsible for generating the actual report in XLSX format. It takes three arguments: workbook, data, and lines.

The GetData method is defined to retrieve data needed for generating the report. It seems to fetch data from a wizard model named 'fm.price.list.wizard' and specifically accesses the data['lines'] field. 

Now you can style the XLSX report as usual under generate_xlsx_report.

The report_xlsx module is a valuable addition to Odoo's reporting capabilities, especially for businesses that rely on analyzing and understanding activities within a venture. While Odoo itself doesn't natively support XLSX report generation, the report_xlsx module fills this gap by enabling users to easily create XLSX reports. By leveraging this module, businesses can empower their users to gain insights from data in a familiar Excel format, facilitating a better understanding of their business activities.

If you need any assistance in odoo, we are online, please chat with us.


Leave a comment




Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message