Picture the report that says 30 when the count says 20
Picture a warehouse manager on a Monday morning. The Stock Balance report says 30 units of an item sit in one warehouse. The physical count says 20.
Nothing has been stolen. Nothing has been double-entered. The report is wrong, and it is wrong in a way that is easy to miss if you only look at totals.
This article walks through the bug, the fix that shipped in ERPNext v16.51.2, and the habits we now use when inventory dimensions are in play.
Where the numbers come from
Stock Balance does not read a balance table. It rebuilds the balance from Stock Ledger Entry rows, one item and warehouse at a time. When you tick Show Dimension Wise Stock (the show_dimension_wise_stock filter), it splits each item-warehouse line by inventory dimension.
The bug report that led to the fix uses a small example, and it is enough to show the problem. The item has 10 units tagged to Project A and 5 units with no dimension at all. The total is 15.
The diagram shows the old path. A Stock Reconciliation sets the count for the whole item and warehouse to 20. That is the right thing to do, because a physical count does not know about projects.
What went wrong
A normal Stock Reconciliation has no inventory dimension. Its entry lands on the row with no dimensions.
The old code computed that row's change as the reconciled quantity minus that row's own balance. That row only held 5 units. So the change came out as 20 minus 5, which is 15.
Add the 15 to the 10 units already in Project A's row and the report shows 30. The reconciliation was correct. The report was not.
The overcount is silent. Nobody gets an error. The total just looks plausible enough to pass a glance.
The fix
The fix is in erpnext/stock/report/stock_balance/stock_balance.py. The pull request is #61732, a backport of #60698 and #60700 into the version-16 branch. It shipped in v16.51.2.
The change is small. The report now keeps an item-warehouse balance next to the per-dimension rows. A new method, get_item_warehouse_balance, fills a dictionary called item_warehouse_balances. The reconciliation change is then computed from that whole-warehouse balance, not from the one row.
In the same example, the change is 20 minus 15, which is 5. The no-dimension row gets a change of 5, and the total comes out at 20. That matches the count.
The PR adds a test, test_reconciliation_without_dimension_in_dimension_wise_stock, in test_stock_balance.py. It uses a Plant dimension (id_plant) and asserts on bal_qty and bal_val. Read that test before you rely on this in production. It is the clearest description of the expected behaviour.
The process that exposed it
The sequence below is what happens from the counter to the report. The bug sat in the last step.
Notice where the reconciliation entry is written. It has no dimension, and it should not need one. The report is the place that has to understand that the entry covers the whole warehouse.
What we do now
Dimension-wise views are still worth ticking when you need to split stock by project, plant or branch. Just do not treat them as the source of truth for a warehouse total.
Three habits help:
- Check the total first. Compare the report total with the physical count before you look at any dimension row.
- Reconcile on purpose. If a count covers the whole warehouse, reconcile the whole warehouse. Do not try to hand-tune the dimension rows to match a number.
- Upgrade and re-check. After moving to v16.51.2 or later, rerun the report for any warehouse where you reconciled with dimensions in play. The report is calculated, so the figures change when the code changes. Ledger entries stay as they were.
The tradeoff is real. Dimension-wise views are the best way to answer "how much of this is Project A?" They are the worst way to answer "how much is in the building?" when the count is taken at warehouse level.
We have not checked every older version for the same pattern. If you run an older v16 build with dimension-wise stock, test one reconciliation before you trust the split.
The takeaway
A report total is a claim. Before you believe it, ask what the report is adding up, and whether that matches what the count actually measured.
Have you seen a dimension-wise report disagree with a physical count? What did you check first, and where did the numbers split?
Have questions about implementing this? Drop us a line — we're happy to help.


