XLSX report in Odoo 18 are a vital tool for businesses and users who want to go beyond standard reporting and create highly customized, professional Excel outputs tailored to their unique needs. If you’re someone who relies on detailed reporting for operations, finance, purchasing, or analytics, then you’re in the right place. Generating a customized XLSX report not only saves time but also ensures data is presented in a way that is clear, insightful, and aligned with your organization’s goals.
In this blog, we’ll walk you step by step through the process of building a Purchase Order XLSX Report in Odoo 18. Rather than sticking to default layouts, this tutorial focuses on showing you how to manage report design through dynamic data extraction, powerful calculations, and clean formatting techniques. By following along, you’ll see how easily raw data can be converted into polished Excel reports using Odoo’s reporting system integration and a bit of structured code development.
Whether you’re an Odoo developer, an HR or finance manager, or simply someone interested in learning the flexibility of the Odoo framework, this guide will help you take reporting to the next level. With the right approach, you’ll not only gain technical know-how but also explore the ability to deliver reports that drive better decisions and make workflows more efficient.
So, if you’ve been wondering how to transform plain reports into customized, professional XLSX documents in Odoo 18, this blog is your roadmap.
Ready to build like a pro? Let’s get started!
What is an XLSX Report in Odoo 18?
XLSX reports in Odoo 18 use Python and the xlsxwriter module to generate Excel files. These are ideal for financial, statistical, or printable tabular data that goes beyond the limitations of Qweb.
Functional Goal
The business requirement is to generate a custom Excel report, for example, purchase orders that include:
- Company branding (logo and name)
- Line-by-line order details with specific formatting
- Summary of payments, discounts, taxes, and total
- Localized currency text
Final polished layout for download/print
Functional Users Involved
- Procurement Officers – Generate purchase order reports quickly for tracking and record-keeping.
- Finance Teams – Validate purchase amounts, discounts, and taxes with precise calculations.
- Auditors – Review well-structured historical records for compliance and transparency.
- Vendors – Receive clear, professional, and branded PO printouts for easy reference.
Custom XLSX Report in Odoo 18 (purchase order)
import io
import base64
from odoo import models
class PurchaseOrderReport(models.AbstractModel):
_name = 'report.module name.report_purchase_order_xlsx'
_inherit = 'report.report_xlsx.abstract'
def generate_xlsx_report(self, workbook, data, orders):
for doc in orders:
worksheet = workbook.add_worksheet('Purchase Order XLSX')
# Define style Formats
title_format = workbook.add_format({
'bold': True, 'font_size': 18, 'align': 'center',
'bg_color': '#d0d0d0', 'border': 1
})
bg_bordered_text_format = workbook.add_format({
'font_size': 11, 'border': 1, 'align': 'top',
'bg_color': '#d0d0d0', 'bold': True
})
bordered_text_format = workbook.add_format({
'font_size': 11, 'border': 1, 'align': 'center'
})
right_align = workbook.add_format({
'border': 1, 'font_size': 11, 'align': 'right'
})
# Add Company Logo
if doc.company_id.logo or doc.company_id.parent_id.logo:
logo_data = io.BytesIO(base64.b64decode(
doc.company_id.parent_id.logo or doc.company_id.logo
))
worksheet.insert_image(0, 11, "company_logo.png", {
'image_data': logo_data, 'x_scale': 0.5, 'y_scale': 0.5
})
# Report Title
worksheet.merge_range(5, 1, 6, 4, 'PURCHASE ORDER', title_format)
# PO Details
worksheet.write(8, 1, 'PO Number:', bold_text_format)
worksheet.write(8, 2, doc.name, text_format)
worksheet.write(9, 1, 'Date:', bold_text_format)
worksheet.write(9, 2, doc.date_order.strftime('%d-%m-%Y'), text_format)
# Table Headers
headers = ["No", "Part Number", "Description", "Qty", "Unit Price", "Discount", "VAT 5%", "Amount"]
for idx, header in enumerate(headers):
worksheet.write(24, idx + 1, header, bg_bordered_text_format)
# Table Content
row = 25
sl_no = 1
total_discount = 0.0
for line in doc.order_line:
worksheet.write(row, 1, sl_no, bordered_text_format)
worksheet.merge_range(row, 2, row, 3, line.product_id.name or "", bordered_text_format)
worksheet.write(row, 10, line.product_qty, bordered_text_format)
worksheet.write(row, 11, f"{line.price_unit:.2f}", right_align)
worksheet.write(row, 12, f"{line.discount:.2f}", right_align)
worksheet.write(row, 13, "%.2f" % sum(line.taxes_id.mapped('amount')), right_align)
worksheet.merge_range(row, 14, row, 15, f"{line.price_subtotal:.2f}", right_align)
total_discount += line.discount
row += 1
sl_no += 1
# Totals Section
worksheet.merge_range(row, 1, row, 11, '*** Payment', bold_left_align)
worksheet.merge_range(row, 12, row, 13, 'Gross:', bold_right_align)
worksheet.merge_range(row, 14, row, 15, f"{doc.amount_untaxed:.2f}", right_align)
worksheet.merge_range(row + 1, 1, row + 1, 11,
f"{doc.currency_id.amount_to_text(doc.amount_total)} ONLY",
bold_left_align)
worksheet.merge_range(row + 5, 12, row + 5, 13, 'Total(AED):', bold_right_align)
worksheet.merge_range(row + 5, 14, row + 5, 15, f"{doc.amount_total:.2f}", right_align)
# Footer
worksheet.merge_range(row + 22, 6, row + 22, 10,
doc.company_id.parent_id.name or doc.company_id.name,
center_bold_text_format)
Register Report Action in XML
Purchase Order XLSX
purchase.order
xlsx
module name.report_purchase_order_xlsx
module name.report_purchase_order_xlsx
(object.state in ('draft', 'sent') and 'Request for Quotation - %s' % (object.name) or
'Purchase Order - %s' % (object.name))
report
This XML registers the report in Odoo and binds it to the purchase.order model.
If you wanted to know about “How to Integrate an External API with Odoo Using XML-RPC?” then you can read this blog.
Bringing Data to Life with XLSX Report in Odoo 18
The journey of creating a fully customized XLSX report in Odoo 18 is now complete. In this tutorial, we explored how to design and manage a Purchase Report layout with dynamic data extraction, accurate calculations, and professional styling. By applying these techniques, you can transform ordinary reports into powerful business insights, tailored exactly to your organizational needs. With Odoo 18, reporting isn’t just about numbers, it’s about clarity, efficiency, and smarter decision-making.



