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
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 |
50 + 40 + 0 = 90
Similarly, another product might have:
Lot/Serial Number | Product | On Hand Quantity |
000000000029 | Drawer | 80 |
Before: Default Odoo Grouped View
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?
As a result, the grouped view can contain the individual values without producing the expected total.
The solution
- Detects when product_qty is being requested with SUM aggregation.
- Processes the relevant records.
- Calculates the quantity for the records belonging to each group.
- Calculates the total in Python.
- 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
Example
This makes the grouped inventory view much easier to understand.
What Does the Module Add?
- 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
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?
- Lots
- Serial numbers
- Products with multiple lots
- Inventory grouped by Product
- Stock quantity analysis
- Warehouse operations
- Inventory reporting
Installation
After installation:
- Open Inventory.
- Go to Lots/Serial Numbers.
- Group the list by Product.
- Check the On Hand Quantity column.
- 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
without changing the standard inventory workflow.