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.
This commit is contained in:
Mihir Kandoi
2026-07-21 16:45:02 +05:30
parent fbde3212e2
commit e7f0461b57

View File

@@ -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,