From 7f1f7809c854ecb8a6e679ea35f553f1dc84faa4 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 15:18:50 +0530 Subject: [PATCH] fix: stock reco negative batch (backport #40533) (#40535) fix: stock reco negative batch (#40533) (cherry picked from commit a64c2ecf396a009bfcaa1e58ad34c61d1b671fe6) Co-authored-by: rohitwaghchaure --- .../serial_and_batch_bundle/serial_and_batch_bundle.py | 7 +++++++ .../doctype/stock_reconciliation/stock_reconciliation.py | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py index 1fb4969e306..58971e8f19d 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py @@ -832,6 +832,13 @@ class SerialandBatchBundle(Document): if not self.has_batch_no: return + if ( + self.voucher_type == "Stock Reconciliation" + and self.type_of_transaction == "Outward" + and frappe.db.get_value("Stock Reconciliation Item", self.voucher_detail_no, "qty") > 0 + ): + return + batches = [d.batch_no for d in self.entries if d.batch_no] if not batches: return diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 3356ad5f300..0311481b6ca 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -154,7 +154,6 @@ class StockReconciliation(StockController): { "current_serial_and_batch_bundle": sn_doc.name, "current_serial_no": "", - "batch_no": "", } )