From 59efe7299ace4caff5906ef04da08ac7272b054d Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 22:10:00 +0530 Subject: [PATCH] fix(stock): narrow legacy serial ledger lookup by item (backport #57499) (#57506) 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. (cherry picked from commit 425191e57e555b3d9b6db9914930d32bbadb5c1c) Co-authored-by: Sudharsanan Ashok <135326972+Sudharsanan11@users.noreply.github.com> --- 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 ba0ccbaf88e..9432e8c59ae 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())