Merge branch 'staging' into develop

This commit is contained in:
Ameya Shenoy
2018-10-11 06:58:53 +00:00
34 changed files with 9067 additions and 8801 deletions

View File

@@ -4,7 +4,29 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import get_link_to_form
from frappe.model.document import Document
class StudentLeaveApplication(Document):
pass
def validate(self):
self.validate_duplicate()
def validate_duplicate(self):
data = frappe.db.sql(""" select name from `tabStudent Leave Application`
where
((%(from_date)s > from_date and %(from_date)s < to_date) or
(%(to_date)s > from_date and %(to_date)s < to_date) or
(%(from_date)s <= from_date and %(to_date)s >= to_date)) and
name != %(name)s and student = %(student)s and docstatus < 2
""", {
'from_date': self.from_date,
'to_date': self.to_date,
'student': self.student,
'name': self.name
}, as_dict=1)
if data:
link = get_link_to_form("Student Leave Application", data[0].name)
frappe.throw(_("Leave application {0} already exists against the student {1}")
.format(link, self.student))