From 076b765cb26629706ee3fb94fa5e8fec64bd4c7f Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 28 May 2025 15:23:37 +0530 Subject: [PATCH] perf: Avoid Querying existence of item code - This should be ensured by Framework. - It's also there in validate hook. So no need to do it again for each item. --- .../doctype/stock_reconciliation/stock_reconciliation.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 4ea683a904d..e41e3ee9662 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -163,8 +163,8 @@ class StockReconciliation(StockController): def set_current_serial_and_batch_bundle(self, voucher_detail_no=None, save=False) -> None: """Set Serial and Batch Bundle for each item""" for item in self.items: - if not frappe.db.exists("Item", item.item_code): - frappe.throw(_("Item {0} does not exist").format(item.item_code)) + if not item.item_code: + continue item_details = frappe.get_cached_value( "Item", item.item_code, ["has_serial_no", "has_batch_no"], as_dict=1 @@ -1011,8 +1011,6 @@ class StockReconciliation(StockController): self._cancel() def recalculate_current_qty(self, voucher_detail_no, sle_creation, add_new_sle=False): - from erpnext.stock.stock_ledger import get_valuation_rate - for row in self.items: if voucher_detail_no != row.name: continue