fix: date validation on student form, instructor duplicacy fix on student grp, instructor with same employee id fix

This commit is contained in:
Khushal Trivedi 2019-12-24 13:37:10 +05:30
parent a65a3d063c
commit ee9aea4feb
3 changed files with 24 additions and 0 deletions

View File

@ -22,3 +22,12 @@ class Instructor(Document):
self.name = self.employee
elif naming_method == 'Full Name':
self.name = self.instructor_name
def validate(self):
self.validate_duplicate_employee()
def validate_duplicate_employee(self):
if self.employee and frappe.db.get_value("Instructor", {'employee': self.employee}, 'name'):
frappe.throw(_("Employee ID is linked with another instructor"))

View File

@ -25,6 +25,9 @@ class Student(Document):
if self.date_of_birth and getdate(self.date_of_birth) >= getdate(today()):
frappe.throw(_("Date of Birth cannot be greater than today."))
if self.joining_date and self.date_of_leaving and getdate(self.joining_date) > getdate(self.date_of_leaving):
frappe.throw(_("Joining Date can not be greater than Leaving Date"))
def update_student_name_in_linked_doctype(self):
linked_doctypes = get_linked_doctypes("Student")
for d in linked_doctypes:

View File

@ -122,3 +122,15 @@ frappe.ui.form.on("Student Group", {
}
}
});
frappe.ui.form.on('Student Group Instructor', {
instructors_add: function(frm){
frm.fields_dict['instructors'].grid.get_field('instructor').get_query = function(doc){
let instructor_list = [];
$.each(doc.instructors, function(idx, val){
instructor_list.push(val.instructor);
});
return { filters: [['Instructor', 'name', 'not in', instructor_list]] };
};
}
});