fix: date validation on student form, instructor duplicacy fix on student grp, instructor with same employee id fix
This commit is contained in:
parent
a65a3d063c
commit
ee9aea4feb
@ -22,3 +22,12 @@ class Instructor(Document):
|
|||||||
self.name = self.employee
|
self.name = self.employee
|
||||||
elif naming_method == 'Full Name':
|
elif naming_method == 'Full Name':
|
||||||
self.name = self.instructor_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"))
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +25,9 @@ class Student(Document):
|
|||||||
if self.date_of_birth and getdate(self.date_of_birth) >= getdate(today()):
|
if self.date_of_birth and getdate(self.date_of_birth) >= getdate(today()):
|
||||||
frappe.throw(_("Date of Birth cannot be greater than 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):
|
def update_student_name_in_linked_doctype(self):
|
||||||
linked_doctypes = get_linked_doctypes("Student")
|
linked_doctypes = get_linked_doctypes("Student")
|
||||||
for d in linked_doctypes:
|
for d in linked_doctypes:
|
||||||
|
@ -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]] };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user