From 2bf9fcb81718f882f33893d53b1bf6019f3a90fd Mon Sep 17 00:00:00 2001 From: Raghav Ruia Date: Wed, 24 Jun 2026 16:06:30 +0530 Subject: [PATCH] feat: confirmation dialog when enabling negative stock on Item Co-Authored-By: Claude Opus 4.8 --- erpnext/stock/doctype/item/item.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index ed6d4efe43d..d4cd4b61f6a 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -54,6 +54,28 @@ frappe.ui.form.on("Item", { } }, + allow_negative_stock(frm) { + if (!frm.doc.allow_negative_stock) { + return; + } + + let msg = __( + "Using negative stock disables FIFO/Moving average valuation when inventory is negative." + ); + msg += " "; + msg += __("This is considered dangerous from accounting point of view."); + msg += "
"; + msg += __("Do you still want to enable negative inventory?"); + + frappe.confirm( + msg, + () => {}, + () => { + frm.set_value("allow_negative_stock", 0); + } + ); + }, + setup: function (frm) { frm.add_fetch("attribute", "numeric_values", "numeric_values"); frm.add_fetch("attribute", "from_range", "from_range");