From 954a5ec006f1d73bd9dddc17aea99364cd246a99 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 13 Aug 2026 16:40:26 +0530 Subject: [PATCH] fix(stock): confirm before changing item qty from the batch selector (backport #58123) (#58124) 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 a2976dd29e9429a43f345a9e693c07aabb2ace9e) Co-authored-by: Sudharsanan Ashok <135326972+Sudharsanan11@users.noreply.github.com> --- .../js/utils/serial_no_batch_selector.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/erpnext/public/js/utils/serial_no_batch_selector.js b/erpnext/public/js/utils/serial_no_batch_selector.js index 91cda58718c..211059ca603 100644 --- a/erpnext/public/js/utils/serial_no_batch_selector.js +++ b/erpnext/public/js/utils/serial_no_batch_selector.js @@ -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( + __( + "Total qty of the rows ({0}) does not match the Qty to Fetch ({1}). Qty of the item will be changed to {0}. 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",