From cf8f4bda8fc4d9521a47168cad220034a3f42b15 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Sun, 12 May 2019 22:45:14 +0530 Subject: [PATCH] fix: skip application fetch for non allocation records --- .../leave_ledger_entry/leave_ledger_entry.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.py b/erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.py index 12be4794aa..23258f1c77 100644 --- a/erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.py +++ b/erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.py @@ -34,12 +34,15 @@ def delete_ledger_entry(ledger): {'transaction_name': ledger.transaction_name}, ['name', 'creation'] ) - leave_application_records = frappe.get_all("Leave Ledger Entry", - filters={ - 'transaction_type': 'Leave Application', - 'creation_date': (">", creation_date) - }, - fields=['transaction_type']) + + leave_application_records = [] + if ledger.transaction_type == "Leave Allocation": + leave_application_records = frappe.get_all("Leave Ledger Entry", + filters={ + 'transaction_type': 'Leave Application', + 'creation_date': (">", creation_date) + }, + fields=['transaction_type']) if not leave_application_records: frappe.delete_doc("Leave Ledger Entry", ledger_entry) else: