leave application overlap validation: consider both open and approved leave applications
This commit is contained in:
parent
c5c48fd147
commit
8b5645d281
@ -123,15 +123,17 @@ class DocType:
|
||||
(self.doc.leave_type,), raise_exception=1)
|
||||
|
||||
def validate_leave_overlap(self):
|
||||
for d in webnotes.conn.sql("""select name, leave_type, posting_date, from_date, to_date
|
||||
for d in webnotes.conn.sql("""select name, leave_type, posting_date,
|
||||
from_date, to_date
|
||||
from `tabLeave Application`
|
||||
where
|
||||
(from_date <= %(to_date)s and to_date >= %(from_date)s)
|
||||
and employee = %(employee)s
|
||||
and docstatus = 1
|
||||
and docstatus < 2
|
||||
and status in ("Open", "Approved")
|
||||
and name != %(name)s""", self.doc.fields, as_dict = 1):
|
||||
|
||||
msgprint("Employee : %s has already applied for %s between %s and %s on %s. Please refer Leave Application : %s" % (self.doc.employee, cstr(d['leave_type']), formatdate(d['from_date']), formatdate(d['to_date']), formatdate(d['posting_date']), d['name']), raise_exception = 1)
|
||||
msgprint("Employee : %s has already applied for %s between %s and %s on %s. Please refer Leave Application : <a href=\"#Form/Leave Application/%s\">%s</a>" % (self.doc.employee, cstr(d['leave_type']), formatdate(d['from_date']), formatdate(d['to_date']), formatdate(d['posting_date']), d['name'], d['name']), raise_exception = 1)
|
||||
|
||||
def validate_max_days(self):
|
||||
max_days = webnotes.conn.sql("select max_days_allowed from `tabLeave Type` where name = '%s'" %(self.doc.leave_type))
|
||||
|
Loading…
x
Reference in New Issue
Block a user