def generate_leave_encashment(): """Generates a draft leave encashment on allocation expiry""" from erpnext.hr.doctype.leave_encashment.leave_encashment import create_leave_encashment if frappe.db.get_single_value("HR Settings", "auto_leave_encashment"): leave_type = frappe.get_all("Leave Type", filters={"allow_encashment": 1}, fields=["name"]) leave_type = [l["name"] for l in leave_type] leave_allocation = frappe.get_all( "Leave Allocation", filters={ "to_date": add_days(today(), -1), "leave_type": ("in", leave_type) }, fields=[ "employee", "leave_period", "leave_type", "to_date", "total_leaves_allocated", "new_leaves_allocated", ], ) create_leave_encashment(leave_allocation=leave_allocation)
def generate_leave_encashment(): ''' Generates a draft leave encashment on allocation expiry ''' from erpnext.hr.doctype.leave_encashment.leave_encashment import create_leave_encashment if frappe.db.get_single_value('HR Settings', 'auto_leave_encashment'): leave_type = frappe.get_all('Leave Type', filters={'allow_encashment': 1}, fields=['name']) leave_type=[l['name'] for l in leave_type] leave_allocation = frappe.get_all("Leave Allocation", filters={ 'to_date': add_days(today(), -1), 'leave_type': ('in', leave_type) }, fields=['employee', 'leave_period', 'leave_type', 'to_date', 'total_leaves_allocated', 'new_leaves_allocated']) create_leave_encashment(leave_allocation=leave_allocation)