mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-08 23:09:33 +00:00
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 <jatinsarna64@gmail.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user