From e7f0461b5757a218e42d4b3e49040bbf77b1a532 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Tue, 21 Jul 2026 16:45:02 +0530 Subject: [PATCH] fix: read serial and batch flags from Item in Stock Balance's SLE query Stock Balance builds stock ageing by passing its own SLE rows into FIFOSlots, whose gates read row.has_batch_no and row.has_serial_no. The query never selected has_batch_no at all, and read has_serial_no from the SLE column, which is unset on rows predating v15's bundle migration (no backfill patch exists). With the flags falsy, incoming batch/serial stock was queued as plain qty slots while outgoing was consumed batch/serial-wise, so the shapes never consume each other, and bundle-based rows resolved no batch details, letting the plain consume path overwrite batch slots in place (flt(batch_no) reads as qty 0). Besides wrong ageing figures, sorting the resulting queue crashed with TypeError: '<' not supported between 'int' and 'datetime.date'. Select both flags from Item, matching Stock Ageing's own query. Only this report is affected; develop dropped the sle_entries pass-in in #44489. --- erpnext/stock/report/stock_balance/stock_balance.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py index 2c25b2c5b2b..715b42c168c 100644 --- a/erpnext/stock/report/stock_balance/stock_balance.py +++ b/erpnext/stock/report/stock_balance/stock_balance.py @@ -384,8 +384,9 @@ class StockBalanceReport: sle.batch_no, sle.serial_no, sle.serial_and_batch_bundle, - sle.has_serial_no, sle.voucher_detail_no, + item_table.has_serial_no, + item_table.has_batch_no, item_table.item_group, item_table.stock_uom, item_table.item_name,