def validate_employee_leave_approver(self): from webnotes.profile import Profile from hr.doctype.leave_application.leave_application import InvalidLeaveApproverError for l in self.doclist.get({"parentfield": "employee_leave_approvers"}): if "Leave Approver" not in Profile(l.leave_approver).get_roles(): msgprint(_("Invalid Leave Approver") + ": \"" + l.leave_approver + "\"", raise_exception=InvalidLeaveApproverError)
def set_default_leave_approver(self): employee_leave_approvers = self.doclist.get({"parentfield": "employee_leave_approvers"}) if len(employee_leave_approvers): webnotes.conn.set_default("leave_approver", employee_leave_approvers[0].leave_approver, self.doc.user_id) elif self.doc.reports_to: from webnotes.profile import Profile reports_to_user = webnotes.conn.get_value("Employee", self.doc.reports_to, "user_id") if "Leave Approver" in Profile(reports_to_user).get_roles(): webnotes.conn.set_default("leave_approver", reports_to_user, self.doc.user_id)