fix: set_query in leave application (#22197)

diff --git a/erpnext/hr/doctype/leave_application/leave_application.js b/erpnext/hr/doctype/leave_application/leave_application.js
index 15ce468..fb1f2c0 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.js
+++ b/erpnext/hr/doctype/leave_application/leave_application.js
@@ -46,6 +46,7 @@
 
 	make_dashboard: function(frm) {
 		var leave_details;
+		let lwps;
 		if (frm.doc.employee) {
 			frappe.call({
 				method: "erpnext.hr.doctype.leave_application.leave_application.get_leave_details",
@@ -61,6 +62,7 @@
 					if (!r.exc && r.message['leave_approver']) {
 						frm.set_value('leave_approver', r.message['leave_approver']);
 					}
+					lwps = r.message["lwps"];
 				}
 			});
 			$("div").remove(".form-dashboard-section.custom");
@@ -70,12 +72,17 @@
 				})
 			);
 			frm.dashboard.show();
+			let allowed_leave_types =  Object.keys(leave_details);
+
+			// lwps should be allowed, lwps don't have any allocation
+			allowed_leave_types = allowed_leave_types.concat(lwps);
+
 			frm.set_query('leave_type', function(){
 				return {
 					filters : [
-						['leave_type_name', 'in', Object.keys(leave_details)]
+						['leave_type_name', 'in', allowed_leave_types]
 					]
-				}
+				};
 			});
 		}
 	},
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index c2b4cdf..0423824 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -19,7 +19,6 @@
 
 from frappe.model.document import Document
 class LeaveApplication(Document):
-
 	def get_feed(self):
 		return _("{0}: From {0} of type {1}").format(self.employee_name, self.leave_type)
 
@@ -463,9 +462,14 @@
 			"pending_leaves": leaves_pending,
 			"remaining_leaves": remaining_leaves}
 
+	#is used in set query
+	lwps = frappe.get_list("Leave Type", filters = {"is_lwp": 1})
+	lwps = [lwp.name for lwp in lwps]
+
 	ret = {
 		'leave_allocation': leave_allocation,
-		'leave_approver': get_leave_approver(employee)
+		'leave_approver': get_leave_approver(employee),
+		'lwps': lwps
 	}
 
 	return ret