def validate_leave_approver(self): employee = webnotes.bean("Employee", self.doc.employee) leave_approvers = [l.leave_approver for l in employee.doclist.get({"parentfield": "employee_leave_approvers"})] if len(leave_approvers) and self.doc.leave_approver not in leave_approvers: msgprint( ( "[" + _("For Employee") + ' "' + self.doc.employee + '"] ' + _("Leave Approver can be one of") + ": " + comma_or(leave_approvers) ), raise_exception=InvalidLeaveApproverError, ) elif self.doc.leave_approver and not webnotes.conn.sql( """select name from `tabUserRole` where parent=%s and role='Leave Approver'""", self.doc.leave_approver, ): msgprint( get_fullname(self.doc.leave_approver) + ": " + _("does not have role 'Leave Approver'"), raise_exception=InvalidLeaveApproverError, )
def validate_order_type(self): valid_types = ["Sales", "Maintenance", "Shopping Cart"] if not self.doc.order_type: self.doc.order_type = "Sales" elif self.doc.order_type not in valid_types: msgprint(_(self.meta.get_label("order_type")) + " " + _("must be one of") + ": " + comma_or(valid_types), raise_exception=True)
def validate(self): if self.doc.buying_or_selling not in ["Buying", "Selling"]: msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " + comma_or(["Buying", "Selling"]), raise_exception=True) # at least one territory self.validate_table_has_rows("valid_for_territories")
def validate_purpose(self): valid_purposes = [ "Material Issue", "Material Receipt", "Material Transfer", "Manufacture/Repack", "Subcontract", "Sales Return", "Purchase Return" ] if self.doc.purpose not in valid_purposes: msgprint(_("Purpose must be one of ") + comma_or(valid_purposes), raise_exception=True)
def validate_purpose(self): valid_purposes = [ "Material Issue", "Material Receipt", "Material Transfer", "Manufacture/Repack", "Subcontract", "Sales Return", "Purchase Return", ] if self.doc.purpose not in valid_purposes: msgprint(_("Purpose must be one of ") + comma_or(valid_purposes), raise_exception=True)
def validate_leave_approver(self): employee = webnotes.bean("Employee", self.doc.employee) leave_approvers = [l.leave_approver for l in employee.doclist.get({"parentfield": "employee_leave_approvers"})] if len(leave_approvers) and self.doc.leave_approver not in leave_approvers: msgprint(("[" + _("For Employee") + ' "' + self.doc.employee + '"] ' + _("Leave Approver can be one of") + ": " + comma_or(leave_approvers)), raise_exception=InvalidLeaveApproverError) elif self.doc.leave_approver and not webnotes.conn.sql("""select name from `tabUserRole` where parent=%s and role='Leave Approver'""", self.doc.leave_approver): msgprint(get_fullname(self.doc.leave_approver) + ": " \ + _("does not have role 'Leave Approver'"), raise_exception=InvalidLeaveApproverError)
def validate(self): if self.doc.buying_or_selling not in ["Buying", "Selling"]: msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " + comma_or(["Buying", "Selling"]), raise_exception=True) if not self.doclist.get({"parentfield": "valid_for_territories"}): # if no territory, set default territory if webnotes.defaults.get_user_default("territory"): self.doclist.append({ "doctype": "Applicable Territory", "parentfield": "valid_for_territories", "territory": webnotes.defaults.get_user_default("territory") }) else: # at least one territory self.validate_table_has_rows("valid_for_territories")
def validate(self): if self.doc.buying_or_selling not in ["Buying", "Selling"]: msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " + comma_or(["Buying", "Selling"]), raise_exception=True) if not self.doclist.get({"parentfield": "valid_for_territories"}): # if no territory, set default territory if webnotes.defaults.get_user_default("territory"): self.doclist.append({ "doctype": "For Territory", "parentfield": "valid_for_territories", "territory": webnotes.defaults.get_user_default("territory") }) else: # at least one territory self.validate_table_has_rows("valid_for_territories")
def validate_status(status, options): if status not in options: msgprint(_("Status must be one of ") + comma_or(options), raise_exception=True)