Odoo 18 is a comprehensive business management platform designed for improved efficiency, automation, and user experience. It enhances key areas such as sales, accounting, inventory, CRM, HR, and eCommerce, while also strengthening security and compliance. With deployment options across Odoo Online, Odoo.sh, and on-premise servers, it adapts to businesses of all sizes. The system, built on Python and PostgreSQL with OWL for frontend development, enables seamless integrations through the REST API. A standout feature is the Pivot Report, which helps businesses analyze data dynamically, apply filters, and generate structured reports for better decision-making. With both a free Community edition and a feature-rich Enterprise edition, Odoo 18 offers a scalable and cost-effective ERP solution.
The Pivot view in Odoo 18 is an advanced reporting tool that helps users efficiently analyze and interpret large volumes of data. It allows businesses to organize information using custom groupings, explore data through drill-down functionality, and generate comprehensive reports for deeper insights. Users can apply filters, restructure data, and track key metrics across various modules like sales, inventory, and finance. Additionally, the Pivot view supports data export, making it a valuable asset for business intelligence and informed decision-making.
Adding Custom Fields to the Sale Report
For example, we can enhance the Sales Report Pivot view by inheriting and extending it. Below is the core structure of the pivot view, which we can modify to include additional fields.

In Odoo, the Sales Report offers crucial insights into sales performance. However, businesses may need additional fields to improve their reporting capabilities. To address this, we can extend the existing sale.report model by introducing custom fields, ensuring they are properly integrated into queries, and correctly grouped for accurate data analysis.
Python:
from odoo import fields, models
class SaleReport(models.Model):
"""Extends Sale Report to include additional fields."""
_inherit = "sale.report"
sale_order_name = fields.Char(string="Sale Order Name")
invoice_status_state = fields.Selection([
('no', 'Not Invoiced'),
('invoiced', 'Fully Invoiced'),
('to invoice', 'To Invoice')
], string="Invoice State")
client_order_ref = fields.Char(string="Customer Reference")
# New Measures
product_count = fields.Integer(string="Number of Products", group_operator="sum")
total_weight = fields.Float(string="Total Product Weight", group_operator="sum")
def _select_additional_fields(self):
"""Adds custom fields to the Sale Report selection query."""
res = super()._select_additional_fields()
res["sale_order_name"] = "s.name"
res["invoice_status_state"] = "s.invoice_status"
res["client_order_ref"] = "s.client_order_ref"
res["product_count"] = "SUM(l.product_uom_qty)" # Sum of product quantities
res["total_weight"] = "SUM(l.product_uom_qty * p.weight)" # Total product weight
return res
def _group_by_sale(self):
"""Adds necessary fields for GROUP BY in the Sale Report query."""
res = super()._group_by_sale()
res += """, s.name, s.invoice_status, s.client_order_ref"""
return res
To make the newly added fields available in the Sale Report, two key methods are overridden:
* _select_additional_fields() – This method extends the selection query to include additional fields and applies necessary aggregations.
* _group_by_sale() – This method ensures that the new fields are properly grouped when fetching data, avoiding query errors.
Creating an XML View to Extend the Pivot Report
To make the newly added fields available in the Sale Report Pivot view, we need to inherit the existing pivot view XML and include our custom fields in the report view.
xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_sale_report_pivot_inherit" model="ir.ui.view">
<field name="name">sale.report.pivot.inherit</field>
<field name="model">sale.report</field>
<field name="inherit_id" ref="sale.view_order_product_pivot"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='team_id']" position="before">
<!-- Add New Measures -->
<field name="product_count" type="measure"/>
<field name="total_weight" type="measure"/>
<!-- Add New Fields -->
<field name="sale_order_name"/>
<field name="invoice_status_state"/>
<field name="client_order_ref"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="sales_report_customisation_search_inherit">
<field name="name">sales.report.search.inherit</field>
<field name="model">sale.report</field>
<field name="inherit_id" ref="sale.view_order_product_search"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='user_id']" position="before">
<group expand="0" string="Group By">
<filter name="Sale Order" context="{'group_by':'sale_order_name'}"/>
<filter name="Invoice State" context="{'group_by':'invoice_status_state'}"/>
<filter name="Customer Reference" context="{'group_by':'client_order_ref'}"/>
</group>
</xpath>
</field>
</record>
</odoo>
Inherited Report View
After installing this custom module with the extended Sale Report model and pivot view modifications, the following results can be observed:

The image above displays the newly added fields: Sale Order Name, Invoice State, and Customer Reference. With these enhancements, we can perform detailed data analysis. For example, in the Pivot View, we can analyze sales data by setting Customer Reference on the horizontal axis (Columns) and Invoice State on the vertical axis (Rows). This setup allows us to visualize the distribution of sales orders across different invoice statuses for each customer, making it easier to identify trends and track pending invoices, as shown in the figure below.

Additionally, by clicking the Measures button, we can access the newly added measures, such as Product Count, Total Product Weight, and Total Weight, as shown in the figure below. This allows for a more in-depth analysis of sales performance based on these key indicators.

When selecting those measures, the result will be as shown in the figure below:

Customizing the sale.report model in Odoo 18 allows businesses to enhance their Pivot View reports by incorporating additional fields and calculations. This customization provides more detailed insights into sales performance, helping businesses make informed decisions based on relevant data.
The approach of extending reports is not exclusive to sale.report, it can also be applied to other Odoo reports like purchase.report, account.invoice.report, and stock.report. By modifying these reports, businesses can tailor their analytics to specific operational needs, ensuring that key information is easily accessible. With these enhancements, users can filter data, group records based on various criteria, and utilize the Measures button to view additional computed values.
Overall, customizing Pivot View reports in Odoo improves visibility into business operations, supports better decision-making, and allows for a more structured and meaningful analysis of critical data.
To read more about How to Inherit Existing Pivot View Report in Odoo 17, refer to our blog How to Inherit Existing Pivot View Report in Odoo 17.