From 425191e57e555b3d9b6db9914930d32bbadb5c1c Mon Sep 17 00:00:00 2001 From: Sudharsanan Ashok <135326972+Sudharsanan11@users.noreply.github.com> Date: Mon, 27 Jul 2026 21:40:44 +0530 Subject: [PATCH] fix(stock): narrow legacy serial ledger lookup by item (#57499) Filter legacy Stock Ledger Entry lookups by item code so the existing item and warehouse index can reduce rows scanned during serial valuation. --- erpnext/stock/deprecated_serial_batch.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/stock/deprecated_serial_batch.py b/erpnext/stock/deprecated_serial_batch.py index 9e097099f01..18affbab66e 100644 --- a/erpnext/stock/deprecated_serial_batch.py +++ b/erpnext/stock/deprecated_serial_batch.py @@ -75,6 +75,7 @@ class DeprecatedSerialNoValuation: | (table.serial_no.like("%\n" + serial_no)) | (table.serial_no.like("%\n" + serial_no + "\n%")) ) + & (table.item_code == self.sle.item_code) & (table.company == self.sle.company) & (table.warehouse == self.sle.warehouse) & (table.serial_and_batch_bundle.isnull())