From ca37f0371b67e0bad27c5bf908abde63ed51490a Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Tue, 18 Nov 2025 15:26:02 +0530 Subject: [PATCH] fix: validate root type as well --- erpnext/accounts/doctype/journal_entry/journal_entry.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 41206275420..aeb8c9970a3 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -326,10 +326,15 @@ class JournalEntry(AccountsController): def validate_depr_account_and_depr_entry_voucher_type(self): for d in self.get("accounts"): + root_type = frappe.get_cached_value("Account", d.account, "root_type") if ( d.reference_type == "Asset" and d.reference_name - and (d.account_type == "Depreciation" or self.voucher_type == "Depreciation Entry") + and ( + d.account_type == "Depreciation" + or self.voucher_type == "Depreciation Entry" + or root_type == "Expense" + ) and d.debit ): if d.account_type != "Depreciation": @@ -340,7 +345,7 @@ class JournalEntry(AccountsController): _("Journal Entry type should be set as Depreciation Entry for asset depreciation") ) - if frappe.get_cached_value("Account", d.account, "root_type") != "Expense": + if root_type != "Expense": frappe.throw(_("Account {0} should be of type Expense").format(d.account)) def validate_stock_accounts(self):