refactor: extract negative stock confirmation into shared util

Deduplicate the identical confirmation dialog used by Item and Stock
Settings into erpnext.utils.confirm_negative_stock, and collapse the
message into a single translatable string.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Raghav Ruia
2026-06-26 09:38:23 +05:30
parent 2bf9fcb817
commit 69d5d2bbc1
3 changed files with 14 additions and 38 deletions

View File

@@ -562,6 +562,18 @@ $.extend(erpnext.utils, {
},
});
erpnext.utils.confirm_negative_stock = function (frm) {
if (!frm.doc.allow_negative_stock) return;
frappe.confirm(
__(
"Using negative stock disables FIFO/Moving average valuation when inventory is negative. This is considered dangerous from accounting point of view.<br>Do you still want to enable negative inventory?"
),
() => {},
() => frm.set_value("allow_negative_stock", 0)
);
};
erpnext.utils.select_alternate_items = function (opts) {
const frm = opts.frm;
const warehouse_field = opts.warehouse_field || "warehouse";