From 8b51005525db6dec5b55bccb6850d705876f88c1 Mon Sep 17 00:00:00 2001 From: Jatin3128 <140256508+Jatin3128@users.noreply.github.com> Date: Mon, 7 Sep 2026 15:27:02 +0530 Subject: [PATCH] fix(journal-entry): avoid full grid re-render per row in set_exchange_rate (backport #58328) (#58803) refresh() loops over every row in the accounts child table and calls set_exchange_rate() for each one. On v16 that function ended with refresh_field("exchange_rate", cdn, "accounts"), which only takes the cheap per-field path when the row is currently rendered. For every row outside the visible page grid_rows_by_docname has no entry, so the helper falls back to a full grid.refresh(): header, pagination and the whole current page get rebuilt once per off-screen row. Use grid.refresh_row(cdn) instead, which re-renders only the row that actually changed and is a no-op for rows outside the current page. This also matches what develop does after #58328. Measured on a 1000-row Journal Entry (v16.local, Chromium): 950 of the 1000 rows triggered a full grid rebuild before, none after. Time to first rendered row ~5.3s to ~1.7s, time to network-idle ~5.9s to ~2.3s, and the set_exchange_rate loop itself ~4.7s to ~1.3s. As a side effect the visible row now stays in sync: previously only the exchange_rate cell was repainted, so the debit/credit columns that set_debit_credit_in_company_currency had just recomputed kept showing stale amounts. Co-authored-by: jatin3128 --- erpnext/accounts/doctype/journal_entry/journal_entry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 3e5a3071c8f..f5b59b0bae6 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -623,7 +623,7 @@ $.extend(erpnext.journal_entry, { } else { erpnext.journal_entry.set_debit_credit_in_company_currency(frm, cdt, cdn); } - refresh_field("exchange_rate", cdn, "accounts"); + frm.get_field("accounts").grid.refresh_row(cdn); }, quick_entry: function (frm) {