mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-17 08:28:44 +00:00
fix(stock): confirm before changing item qty from the batch selector (#58123)
the batch selector silently overwrote the item qty with the bundle total,
so editing a row qty in the dialog changed the delivered qty without any
warning. prompt for confirmation when the rows do not add up to the qty
to fetch, and only proceed if the user agrees.
(cherry picked from commit a2976dd29e)
Co-authored-by: Sudharsanan Ashok <135326972+Sudharsanan11@users.noreply.github.com>
This commit is contained in:
@@ -658,6 +658,27 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
||||
frappe.throw(__("Rejected Warehouse and Accepted Warehouse cannot be same."));
|
||||
}
|
||||
|
||||
let qty_to_fetch = flt(this.dialog.get_value("qty"));
|
||||
let total_qty = entries.reduce((total, row) => total + (flt(row.qty) || 1.0), 0);
|
||||
|
||||
if (flt(total_qty, 6) !== flt(qty_to_fetch, 6)) {
|
||||
const confirm_dialog = frappe.confirm(
|
||||
__(
|
||||
"<strong>Total qty</strong> of the rows (<strong>{0}</strong>) does not match the <strong>Qty to Fetch</strong> (<strong>{1}</strong>). Qty of the item will be changed to <strong>{0}</strong>. Are you sure want to proceed?",
|
||||
[format_number(total_qty), format_number(qty_to_fetch)]
|
||||
),
|
||||
() => this.create_bundle_entries(entries, warehouse)
|
||||
);
|
||||
confirm_dialog.indicator = "blue";
|
||||
confirm_dialog.set_indicator();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.create_bundle_entries(entries, warehouse);
|
||||
}
|
||||
|
||||
create_bundle_entries(entries, warehouse) {
|
||||
frappe
|
||||
.call({
|
||||
method: "erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.add_serial_batch_ledgers",
|
||||
|
||||
Reference in New Issue
Block a user