feat: confirmation dialog when enabling negative stock on Item

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Raghav Ruia
2026-06-24 16:06:30 +05:30
parent 9b0e1b61f2
commit 2bf9fcb817

View File

@@ -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 += "<br>";
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");