fix: validation for attendance marked on future dates
This commit is contained in:
parent
6c3efbdb48
commit
8b4d33474e
@ -6,13 +6,13 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe import _
|
||||
from frappe.utils import get_link_to_form
|
||||
from frappe.utils import get_link_to_form, getdate
|
||||
from erpnext.education.api import get_student_group_students
|
||||
|
||||
|
||||
class StudentAttendance(Document):
|
||||
def validate(self):
|
||||
self.validate_mandatory()
|
||||
self.validate_date()
|
||||
self.set_date()
|
||||
self.set_student_group()
|
||||
self.validate_student()
|
||||
@ -27,6 +27,10 @@ class StudentAttendance(Document):
|
||||
frappe.throw(_('{0} or {1} is mandatory').format(frappe.bold('Student Group'),
|
||||
frappe.bold('Course Schedule')), title=_('Mandatory Fields'))
|
||||
|
||||
def validate_date(self):
|
||||
if getdate(self.date) > getdate():
|
||||
frappe.throw(_('Attendance cannot be marked for future dates.'))
|
||||
|
||||
def set_student_group(self):
|
||||
if self.course_schedule:
|
||||
self.student_group = frappe.db.get_value('Course Schedule', self.course_schedule, 'student_group')
|
||||
|
@ -52,6 +52,8 @@ frappe.ui.form.on('Student Attendance Tool', {
|
||||
},
|
||||
|
||||
date: function(frm) {
|
||||
if (frm.doc.date > frappe.datetime.get_today())
|
||||
frappe.throw(__("Cannot mark attendance for future dates."));
|
||||
frm.trigger("student_group");
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user