fix(bank-integration): re-add BRT checkbox column on every "Get Unreconciled Entries"

The checkbox column + Create & Reconcile toolbar setup was on the form's
`refresh` event, which fires only once. On a second "Get Unreconciled
Entries" ERPNext rebuilds the DataTableManager without the checkbox
column and the polling interval never restarted. Moved the enhancement
to the `render` event (fires on every rebuild), matching the pattern
the kapital_bank BRT extension used. The prototype patch that adds the
"Bank Transaction" column stays on `refresh` since it is idempotent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ali 2026-05-11 13:02:53 +00:00
parent f1876b6088
commit b4b1d1b9b6
1 changed files with 6 additions and 2 deletions

View File

@ -12,6 +12,7 @@ frappe.ui.form.on("Bank Reconciliation Tool", {
// Make BRT fill the page (existing fallback) // Make BRT fill the page (existing fallback)
frm.$wrapper.closest('.page-container').css('--page-max-width', 'none'); frm.$wrapper.closest('.page-container').css('--page-max-width', 'none');
// Patch the DataTableManager prototype once: adds the "Bank Transaction" column.
frappe.require("bank-reconciliation-tool.bundle.js", function () { frappe.require("bank-reconciliation-tool.bundle.js", function () {
const DTM = erpnext.accounts.bank_reconciliation.DataTableManager; const DTM = erpnext.accounts.bank_reconciliation.DataTableManager;
if (!DTM || DTM.prototype._jey_erp_patched) return; if (!DTM || DTM.prototype._jey_erp_patched) return;
@ -43,9 +44,12 @@ frappe.ui.form.on("Bank Reconciliation Tool", {
proto._jey_erp_patched = true; proto._jey_erp_patched = true;
}); });
},
// === 2 + 3: checkbox column + Create & Reconcile toolbar === // `render` fires every time the reconciliation tool is (re)built — i.e. on
// We poll for the DataTableManager instance on the form, then enhance once. // every "Get Unreconciled Entries". Each time a brand-new DataTableManager
// is created, so we re-poll for it and re-add the checkbox column + toolbar.
render(frm) {
if (frm._bi_check_interval) clearInterval(frm._bi_check_interval); if (frm._bi_check_interval) clearInterval(frm._bi_check_interval);
frm._bi_check_interval = setInterval(function () { frm._bi_check_interval = setInterval(function () {
const dtm = frm.bank_reconciliation_data_table_manager; const dtm = frm.bank_reconciliation_data_table_manager;