Merge pull request #300 from mayur-patel/master

Allow user to add leave application which may results in negative balance.
This commit is contained in:
Rushabh Mehta 2013-03-05 01:27:26 -08:00
commit c4529ebb0d
2 changed files with 14 additions and 6 deletions

View File

@ -124,11 +124,13 @@ class DocType(DocListController):
if not is_lwp(self.doc.leave_type):
self.doc.leave_balance = get_leave_balance(self.doc.employee,
self.doc.leave_type, self.doc.fiscal_year)["leave_balance"]
if self.doc.leave_balance - self.doc.total_leave_days < 0:
msgprint("There is not enough leave balance for Leave Type: %s" % \
(self.doc.leave_type,), raise_exception=1)
if self.doc.leave_balance - self.doc.total_leave_days < 0:
#check if this leave type allow the remaining balance to be in negative. If yes then warn the user and continue to save else warn the user and don't save.
msgprint("There is not enough leave balance for Leave Type: %s" % \
(self.doc.leave_type,),
raise_exception=not(webnotes.conn.get_value("Leave Type", self.doc.leave_type,"allow_negative") or None))
def validate_leave_overlap(self):
if not self.doc.name:
self.doc.name = "New Leave Application"

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-01-10 16:34:15",
"creation": "2013-02-21 09:55:58",
"docstatus": 0,
"modified": "2013-01-22 14:47:02",
"modified": "2013-03-05 08:06:43",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -91,6 +91,12 @@
"fieldtype": "Check",
"label": "Is LWP"
},
{
"doctype": "DocField",
"fieldname": "allow_negative",
"fieldtype": "Check",
"label": "Allow Negative Balance"
},
{
"doctype": "DocPerm",
"role": "System Manager"