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.
This commit is contained in:
Ankush Menat
2025-05-28 15:23:37 +05:30
parent 4d98094783
commit 076b765cb2

View File

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