fix: set_query in leave application (#22197)
This commit is contained in:
parent
ee6f80e25b
commit
7558e64d6d
@ -46,6 +46,7 @@ frappe.ui.form.on("Leave Application", {
|
||||
|
||||
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 @@ frappe.ui.form.on("Leave Application", {
|
||||
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 @@ frappe.ui.form.on("Leave Application", {
|
||||
})
|
||||
);
|
||||
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]
|
||||
]
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -19,7 +19,6 @@ class NotAnOptionalHoliday(frappe.ValidationError): pass
|
||||
|
||||
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 @@ def get_leave_details(employee, date):
|
||||
"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
|
||||
|
Loading…
x
Reference in New Issue
Block a user