mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-13 06:31:48 +00:00
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:
@@ -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";
|
||||
|
||||
@@ -55,25 +55,7 @@ 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);
|
||||
}
|
||||
);
|
||||
erpnext.utils.confirm_negative_stock(frm);
|
||||
},
|
||||
|
||||
setup: function (frm) {
|
||||
|
||||
@@ -96,25 +96,7 @@ frappe.ui.form.on("Stock Settings", {
|
||||
},
|
||||
|
||||
allow_negative_stock: function (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);
|
||||
}
|
||||
);
|
||||
erpnext.utils.confirm_negative_stock(frm);
|
||||
},
|
||||
auto_insert_price_list_rate_if_missing(frm) {
|
||||
if (!frm.doc.auto_insert_price_list_rate_if_missing) return;
|
||||
|
||||
Reference in New Issue
Block a user