From 1322cc1378be8a57a8451fef655dc7a5f5b77e5c Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 14 Jul 2025 16:25:29 +0530 Subject: [PATCH] fix: incorrect stock reco sle (cherry picked from commit 597d5aff0246ca7876e2d25056a3ff8f293a033b) --- .../stock_reconciliation.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index fee71460ee5..d35666ba690 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -1089,17 +1089,14 @@ class StockReconciliation(StockController): } ) - if ( - add_new_sle - and not frappe.db.get_value( - "Stock Ledger Entry", - {"voucher_detail_no": row.name, "actual_qty": ("<", 0), "is_cancelled": 0}, - "name", - ) - and not row.current_serial_and_batch_bundle + if add_new_sle and not frappe.db.get_value( + "Stock Ledger Entry", + {"voucher_detail_no": row.name, "actual_qty": ("<", 0), "is_cancelled": 0}, + "name", ): - self.set_current_serial_and_batch_bundle(voucher_detail_no, save=True) - row.reload() + if not not row.current_serial_and_batch_bundle: + self.set_current_serial_and_batch_bundle(voucher_detail_no, save=True) + row.reload() self.add_missing_stock_ledger_entry(row, voucher_detail_no, sle_creation)