Skip to Content

Odoo Grouped On Hand Quantity: How to Show SUM for Lots/Serial Numbers

August 8, 2026 by
Odoo Grouped On Hand Quantity: How to Show SUM for Lots/Serial Numbers
Administrator

Introduction


When working with inventory in Odoo, the Lots/Serial Numbers view provides useful information about stock quantities for individual lots.

However, there is an important limitation when the list is grouped by Product.

The individual lot records can show their On Hand Quantity, but the grouped product row may not display the expected SUM of those quantities.

For businesses that manage multiple lots for the same product, this can make the grouped inventory view less useful.

In this article, we will look at the problem, understand why it happens, and see how a Python-based solution can provide accurate grouped On Hand Quantity totals.

The problem

Go to:

Inventory → Products → Lots/Serial Numbers

Then group the list by Product.
For example, suppose we have the following lots:


Lot/Serial Number

Product

On Hand Quantity

CM-BOX-00001

Cable Management Box

50

CM-BOX-00002

Cable Management Box

40

LOT-000001

Cable Management Box

40

The total quantity is:
50 + 40 + 0 = 90
Similarly, another product might have:



Lot/Serial Number

Product

On Hand Quantity

000000000029

Drawer

80

However, the standard grouped view does not provide the required SUM for the computed On Hand Quantity field.

Before: Default Odoo Grouped View

In the standard Odoo behavior, the records can be grouped by Product and each individual lot displays its On Hand Quantity.

But the grouped product row does not calculate the total of the quantities underneath it.

For example:

[FURN_5555] Cable Management Box (3)       -

CM-BOX-00001 50.00
CM-BOX-00002 40.00
LOT-000001 0.00

[FURN_8855] Drawer (1) -

000000000029 80.00

The expected value for Cable Management Box is:

50 + 40 + 0 = 90

But the grouped row does not show this SUM.

Why Doesn't the SUM Work?

The On Hand Quantity field involved here is a computed field.

Unlike a normal stored database field, its value is calculated by Odoo rather than simply being stored as a column that can be directly aggregated by SQL.

This becomes important when Odoo processes grouped list views.

Odoo's grouping mechanisms such as read_group() / _read_group() are designed to perform aggregation efficiently at the database level where possible.

For a computed quantity such as product_qty, the standard SQL aggregation approach cannot simply calculate the required grouped SUM in the same way as a regular stored numeric field.


As a result, the grouped view can contain the individual values without producing the expected total.

The solution

The solution is to calculate the grouped quantity in Python.

Instead of depending on SQL to aggregate the computed field, the module:

  1. Detects when product_qty is being requested with SUM aggregation.
  2. Processes the relevant records.
  3. Calculates the quantity for the records belonging to each group.
  4. Calculates the total in Python.
  5. Injects the calculated value into the grouped result.

This allows the grouped list view to display the expected On Hand Quantity.


After: Accurate Grouped On Hand Quantity

After installing the On Hand Qty Sum module, the same grouped view can display the calculated totals.

[FURN_5555] Cable Management Box (3)      90.00

CM-BOX-00001 50.00
CM-BOX-00002 40.00
LOT-000001 0.00

[FURN_8855] Drawer (1) 80.00

000000000029 80.00
Now the grouped quantity is immediately visible.

Example

For Cable Management Box:

50 + 40 + 0 = 90

For Drawer:

80 = 80

This makes the grouped inventory view much easier to understand.

What Does the Module Add?

The module is designed specifically for this use case.

Key features
  • SUM for On Hand Quantity
  • Supports grouping Lots/Serial Numbers by Product
  • Python-level aggregation for the computed quantity
  • Works with the standard Odoo inventory list view
  • No separate reporting screen required
  • Keeps the existing Odoo workflow

Example Use Case

Imagine a company has hundreds of lots for different products.

A product may have:

Lot A → 25 units
Lot B → 40 units
Lot C → 15 units
Lot D → 20 units

The total available quantity is:

25 + 40 + 15 + 20 = 100 units

When the inventory is grouped by Product, users usually want to know:

How many units of this product are available across all its lots?

The module makes this total visible directly in the grouped row.

Who Can Benefit From This Module?

This can be useful for Odoo databases where inventory users frequently work with:

  • Lots
  • Serial numbers
  • Products with multiple lots
  • Inventory grouped by Product
  • Stock quantity analysis
  • Warehouse operations
  • Inventory reporting
It can be especially useful when users need a quick overview without opening every individual lot.
Get the Module

Installation

Install the module from your Odoo Apps interface.

After installation:

  1. Open Inventory.
  2. Go to Lots/Serial Numbers.
  3. Group the list by Product.
  4. Check the On Hand Quantity column.
  5. The grouped rows will display the calculated SUM.

See It in Action


The following before-and-after example demonstrates the difference between the standard grouped view and the view with the module installed.

Before: The grouped Product rows do not display the On Hand Quantity SUM.

After: The grouped Product rows display the calculated total.

You can also watch the complete demonstration:

Watch the demo video on YouTube

Conclusion

Odoo provides powerful inventory management and grouping capabilities, but computed fields can create limitations when aggregation is required.

For the Lots/Serial Numbers view, users may want to group records by Product and immediately see the total On Hand Quantity across all related lots.

The On Hand Qty Sum module addresses this limitation by calculating the SUM of the computed product_qty field in Python and adding the result to the grouped view.

This provides a simple way to get:

Product → Total On Hand Quantity

without changing the standard inventory workflow.


Get the Module

If you need accurate On Hand Quantity totals when grouping Lots/Serial Numbers by Product, Download the module from odoo apps store