From 56efe5e82c3b1eba78be4b16d183131b1f5d5c44 Mon Sep 17 00:00:00 2001 From: Sagar Vora <16315650+sagarvora@users.noreply.github.com> Date: Fri, 13 Mar 2026 23:03:13 +0530 Subject: [PATCH 1/2] fix: exempt ledger entries and account closing balance from auto-cancellation --- erpnext/hooks.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 1132ce8814c..955d7dc4ef4 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -418,11 +418,19 @@ naming_series_variables = { for variable in naming_series_variables_list } -# On cancel event Payment Entry will be exempted and all linked submittable doctype will get cancelled. -# to maintain data integrity we exempted payment entry. it will un-link when sales invoice get cancelled. -# if payment entry not in auto cancel exempted doctypes it will cancel payment entry. auto_cancel_exempted_doctypes = [ + # On cancel event Payment Entry will be exempted and all linked submittable doctype will get cancelled. + # to maintain data integrity we exempted payment entry. it will un-link when sales invoice get cancelled. + # if payment entry not in auto cancel exempted doctypes it will cancel payment entry. "Payment Entry", + # Reverse ledger entries are created instead to ensure ledger immutability. + "GL Entry", + "Stock Ledger Entry", + "Payment Ledger Entry", + "Advance Payment Ledger Entry", + # May be linked to Period Closing Voucher, but cancelled with custom logic in PCV. + # This is better to avoid stale docs when cancelling PCV from backend. + "Account Closing Balance", ] scheduler_events = { From c069a1787db571d5bd19f013f7eff295a4172d1b Mon Sep 17 00:00:00 2001 From: Sagar Vora <16315650+sagarvora@users.noreply.github.com> Date: Fri, 13 Mar 2026 23:20:42 +0530 Subject: [PATCH 2/2] fix: hide cancel button from ledger / closing balance doctypes --- .../account_closing_balance/account_closing_balance.js | 10 +++++----- .../advance_payment_ledger_entry.js | 1 + .../payment_ledger_entry/payment_ledger_entry.js | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/account_closing_balance/account_closing_balance.js b/erpnext/accounts/doctype/account_closing_balance/account_closing_balance.js index e35591474b1..d5d109a324f 100644 --- a/erpnext/accounts/doctype/account_closing_balance/account_closing_balance.js +++ b/erpnext/accounts/doctype/account_closing_balance/account_closing_balance.js @@ -1,8 +1,8 @@ // Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -// frappe.ui.form.on("Account Closing Balance", { -// refresh(frm) { - -// }, -// }); +frappe.ui.form.on("Account Closing Balance", { + refresh(frm) { + frm.page.btn_secondary.hide(); + }, +}); diff --git a/erpnext/accounts/doctype/advance_payment_ledger_entry/advance_payment_ledger_entry.js b/erpnext/accounts/doctype/advance_payment_ledger_entry/advance_payment_ledger_entry.js index 24b82fa8025..bf9abdbc21c 100644 --- a/erpnext/accounts/doctype/advance_payment_ledger_entry/advance_payment_ledger_entry.js +++ b/erpnext/accounts/doctype/advance_payment_ledger_entry/advance_payment_ledger_entry.js @@ -3,6 +3,7 @@ frappe.ui.form.on("Advance Payment Ledger Entry", { refresh(frm) { + frm.page.btn_secondary.hide(); frm.set_currency_labels(["amount"], frm.doc.currency); frm.set_currency_labels(["base_amount"], erpnext.get_currency(frm.doc.company)); }, diff --git a/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.js b/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.js index 07fe83177ba..1d54968144b 100644 --- a/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.js +++ b/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.js @@ -2,6 +2,7 @@ // For license information, please see license.txt frappe.ui.form.on("Payment Ledger Entry", { - // refresh: function(frm) { - // } + refresh(frm) { + frm.page.btn_secondary.hide(); + }, });