From e932105ee3912117ba78b65d46586152292994f3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sun, 19 Jul 2026 12:26:34 +0530 Subject: [PATCH] fix(selling): recompute proforma amount for all rows on qty change Refreshing a single grid row only updates the active row, so the derived amount for rows after the edited one went stale. Recompute every row's amount from qty x rate and re-render the grid. --- erpnext/public/js/sales_order_proforma.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/erpnext/public/js/sales_order_proforma.js b/erpnext/public/js/sales_order_proforma.js index 3d24cc22bb2..5989d32fe0d 100644 --- a/erpnext/public/js/sales_order_proforma.js +++ b/erpnext/public/js/sales_order_proforma.js @@ -123,11 +123,15 @@ Object.assign(erpnext.proforma, { label: __("Qty"), in_list_view: 1, onchange: function () { - // In Quantity basis, Amount is derived (qty x rate). In Amount basis - // both are user-entered, so leave Amount alone. - if (this.doc && dialog.get_value("based_on") === "Quantity") { - this.doc.amount = flt(this.doc.qty) * flt(this.doc.rate); - this.grid_row?.refresh_field("amount"); + // In Quantity basis, Amount is derived (qty x rate). Recompute across + // all rows and re-render — refreshing a single row only updates the + // active one, so rows beyond the edited one would go stale. + if (dialog.get_value("based_on") === "Quantity") { + const grid = dialog.get_field("items").grid; + (grid.grid_rows || []).forEach((row) => { + if (row.doc) row.doc.amount = flt(row.doc.qty) * flt(row.doc.rate); + }); + grid.refresh(); } erpnext.proforma.update_warning(dialog); },