Merge pull request #300 from mayur-patel/master

Allow user to add leave application which may results in negative balance.
diff --git a/hr/doctype/leave_application/leave_application.py b/hr/doctype/leave_application/leave_application.py
index e8cc446..f2a58c8 100755
--- a/hr/doctype/leave_application/leave_application.py
+++ b/hr/doctype/leave_application/leave_application.py
@@ -124,11 +124,13 @@
 			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"
diff --git a/hr/doctype/leave_type/leave_type.txt b/hr/doctype/leave_type/leave_type.txt
index 5524bcf..3087caa 100644
--- a/hr/doctype/leave_type/leave_type.txt
+++ b/hr/doctype/leave_type/leave_type.txt
@@ -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"
  }, 
@@ -92,6 +92,12 @@
   "label": "Is LWP"
  }, 
  {
+  "doctype": "DocField", 
+  "fieldname": "allow_negative", 
+  "fieldtype": "Check", 
+  "label": "Allow Negative Balance"
+ }, 
+ {
   "doctype": "DocPerm", 
   "role": "System Manager"
  },