From f4498307c6a031ce7568c2d6b7b3e96b5e08480b Mon Sep 17 00:00:00 2001 From: RobertSchouten Date: Fri, 9 Sep 2016 11:35:51 +0800 Subject: [PATCH] fix allow negatives in leave type check --- erpnext/hr/doctype/leave_allocation/leave_allocation.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.py b/erpnext/hr/doctype/leave_allocation/leave_allocation.py index 331a82bd8a..86ed18718e 100755 --- a/erpnext/hr/doctype/leave_allocation/leave_allocation.py +++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.py @@ -87,7 +87,10 @@ class LeaveAllocation(Document): self.from_date, self.to_date) if flt(leaves_taken) > flt(self.total_leaves_allocated): - frappe.throw(_("Total allocated leaves {0} cannot be less than already approved leaves {1} for the period").format(self.total_leaves_allocated, leaves_taken), LessAllocationError) + if frappe.db.get_value("Leave Type", self.leave_type, "allow_negative"): + frappe.msgprint(_("Note: Total allocated leaves {0} shouldn't be less than already approved leaves {1} for the period").format(self.total_leaves_allocated, leaves_taken), LessAllocationError) + else: + frappe.throw(_("Total allocated leaves {0} cannot be less than already approved leaves {1} for the period").format(self.total_leaves_allocated, leaves_taken), LessAllocationError) @frappe.whitelist() def get_carry_forwarded_leaves(employee, leave_type, date, carry_forward=None): @@ -113,4 +116,4 @@ def get_carry_forwarded_leaves(employee, leave_type, date, carry_forward=None): def validate_carry_forward(leave_type): if not frappe.db.get_value("Leave Type", leave_type, "is_carry_forward"): frappe.throw(_("Leave Type {0} cannot be carry-forwarded").format(leave_type)) - \ No newline at end of file +