From 7355fce75e9c5084e4583c6510e66702cce8e94e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 22 Feb 2024 11:39:48 +0530 Subject: [PATCH] fix: negative stock error while making stock reconciliation (backport #40016) (#40025) * fix: negative stock error while making stock reconciliation (#40016) fix: negative stock error while making stock reco (cherry picked from commit da184d709b9f61bc9bd62cd6beddf5e19c661042) # Conflicts: # erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py * chore: fix conflicts * chore: fix linter issue --------- Co-authored-by: rohitwaghchaure (cherry picked from commit 865cba406f7826501e33853052d15665d6b72448) --- .../doctype/stock_reconciliation/stock_reconciliation.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 9a46ae71ad2..44c2d85b4cc 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -699,8 +699,13 @@ class StockReconciliation(StockController): def has_negative_stock_allowed(self): allow_negative_stock = cint(frappe.db.get_single_value("Stock Settings", "allow_negative_stock")) + if allow_negative_stock: + return True - if all(d.batch_no and flt(d.qty) == flt(d.current_qty) for d in self.items): + if any( + (d.batch_no and flt(d.qty) == flt(d.current_qty)) + for d in self.items + ): allow_negative_stock = True return allow_negative_stock