From 8a1e38a43b8f47ef388a5d7f57b8e84212bbe2b3 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 7 Oct 2024 22:14:10 +0530 Subject: [PATCH] chore: Allow apps to extend voucher subtypes --- erpnext/controllers/accounts_controller.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 328b2b76346..9f2190560c5 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1069,9 +1069,11 @@ class AccountsController(TransactionBase): "Asset Capitalization": "entry_type", } - extended_voucher_types = frappe.get_hooks("voucher_subtypes") or {} - for key, value in extended_voucher_types.items(): - voucher_subtypes[key] = value[0] + for method_name in frappe.get_hooks("voucher_subtypes"): + voucher_subtype = frappe.get_attr(method_name)(self) + + if voucher_subtype: + return voucher_subtype if self.doctype in voucher_subtypes: return self.get(voucher_subtypes[self.doctype])