diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.js b/erpnext/hr/doctype/leave_allocation/leave_allocation.js index d01f1ba380e..b7e1f45a15c 100755 --- a/erpnext/hr/doctype/leave_allocation/leave_allocation.js +++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.js @@ -11,6 +11,13 @@ frappe.ui.form.on("Leave Allocation", { return { query: "erpnext.controllers.queries.employee_query" } + }); + frm.set_query("leave_type", function() { + return { + filters: { + is_lwp: 0 + } + } }) }, diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.py b/erpnext/hr/doctype/leave_allocation/leave_allocation.py index 86ed18718ec..3473fd841a2 100755 --- a/erpnext/hr/doctype/leave_allocation/leave_allocation.py +++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.py @@ -23,6 +23,7 @@ class LeaveAllocation(Document): self.validate_back_dated_allocation() self.set_total_leaves_allocated() self.validate_total_leaves_allocated() + self.validate_lwp() set_employee_name(self) def on_update_after_submit(self): @@ -37,6 +38,10 @@ class LeaveAllocation(Document): def validate_period(self): if date_diff(self.to_date, self.from_date) <= 0: frappe.throw(_("To date cannot be before from date")) + + def validate_lwp(self): + if frappe.db.get_value("Leave Type", self.leave_type, "is_lwp"): + frappe.throw(_("Leave Type {0} cannot be allocated since it is leave without pay").format(self.leave_type)) def validate_new_leaves_allocated_value(self): """validate that leave allocation is in multiples of 0.5"""