From 4c094c3d8614d7d49cbdbfad3d9b97317fda39df Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 9 Feb 2026 15:04:19 +0530 Subject: [PATCH 1/2] feat: allow negative stock for the batch item (cherry picked from commit 376ab0e34649d8d93fc9001dfb4f1f702b42476d) # Conflicts: # erpnext/stock/doctype/stock_settings/stock_settings.json --- .../serial_and_batch_bundle.py | 3 +++ .../stock/doctype/stock_settings/stock_settings.json | 12 ++++++++++++ .../stock/doctype/stock_settings/stock_settings.py | 1 + 3 files changed, 16 insertions(+) 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 f51254784d9..a0091bb7c6f 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 @@ -1429,6 +1429,9 @@ class SerialandBatchBundle(Document): def throw_negative_batch(self, batch_no, available_qty, precision): from erpnext.stock.stock_ledger import NegativeStockError + if frappe.db.get_single_value("Stock Settings", "allow_negative_stock_for_batch"): + return + frappe.throw( _( """ diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.json b/erpnext/stock/doctype/stock_settings/stock_settings.json index d61c8f575cb..ed1417ad6cb 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.json +++ b/erpnext/stock/doctype/stock_settings/stock_settings.json @@ -47,6 +47,7 @@ "disable_serial_no_and_batch_selector", "use_serial_batch_fields", "do_not_update_serial_batch_on_creation_of_auto_bundle", + "allow_negative_stock_for_batch", "serial_and_batch_bundle_section", "set_serial_and_batch_bundle_naming_based_on_naming_series", "section_break_gnhq", @@ -538,6 +539,13 @@ "fieldname": "validate_material_transfer_warehouses", "fieldtype": "Check", "label": "Validate Material Transfer Warehouses" + }, + { + "default": "0", + "description": "If enabled, the system will allow negative stock entries for the batch, but this could calculate the valuation rate incorrectly, so avoid using this option.", + "fieldname": "allow_negative_stock_for_batch", + "fieldtype": "Check", + "label": "Allow Negative Stock for Batch" } ], "icon": "icon-cog", @@ -545,7 +553,11 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], +<<<<<<< HEAD "modified": "2025-11-11 11:35:39.864923", +======= + "modified": "2026-02-09 15:01:12.466175", +>>>>>>> 376ab0e346 (feat: allow negative stock for the batch item) "modified_by": "Administrator", "module": "Stock", "name": "Stock Settings", diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.py b/erpnext/stock/doctype/stock_settings/stock_settings.py index 268d1570b08..0ea1738b60e 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.py +++ b/erpnext/stock/doctype/stock_settings/stock_settings.py @@ -30,6 +30,7 @@ class StockSettings(Document): allow_from_pr: DF.Check allow_internal_transfer_at_arms_length_price: DF.Check allow_negative_stock: DF.Check + allow_negative_stock_for_batch: DF.Check allow_partial_reservation: DF.Check allow_to_edit_stock_uom_qty_for_purchase: DF.Check allow_to_edit_stock_uom_qty_for_sales: DF.Check From 7f69556c45963f51a8f9494436edff67d437e495 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Mon, 9 Feb 2026 16:31:33 +0530 Subject: [PATCH 2/2] chore: fix conflicts --- erpnext/stock/doctype/stock_settings/stock_settings.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.json b/erpnext/stock/doctype/stock_settings/stock_settings.json index ed1417ad6cb..9e6eb8d6f2d 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.json +++ b/erpnext/stock/doctype/stock_settings/stock_settings.json @@ -553,11 +553,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], -<<<<<<< HEAD - "modified": "2025-11-11 11:35:39.864923", -======= "modified": "2026-02-09 15:01:12.466175", ->>>>>>> 376ab0e346 (feat: allow negative stock for the batch item) "modified_by": "Administrator", "module": "Stock", "name": "Stock Settings",