From 7ba7d1a2a4bb9f8f61f180ec10dd52dc82f4ae6d Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 7 May 2025 20:56:05 +0530 Subject: [PATCH] fix: error while making SABB for backdated stock reco (cherry picked from commit ad25636afb10ea35469c27de0275ed2f93661594) --- .../stock_reconciliation/stock_reconciliation.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 76a540f3e92..4ea683a904d 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -203,9 +203,19 @@ class StockReconciliation(StockController): ) ) - if self.docstatus == 1: - bundle.voucher_no = self.name - bundle.submit() + if ( + self.docstatus == 1 + and item.current_serial_and_batch_bundle + and frappe.db.get_value( + "Serial and Batch Bundle", item.current_serial_and_batch_bundle, "docstatus" + ) + == 0 + ): + sabb_doc = frappe.get_doc( + "Serial and Batch Bundle", item.current_serial_and_batch_bundle + ) + sabb_doc.voucher_no = self.name + sabb_doc.submit() item.db_set( {