Example #1
0
def check_record(d):
    """check for mandatory, select options, dates. these should ideally be in doclist"""
    from frappe.utils.dateutils import parse_date
    doc = frappe.get_doc(d)
    frappe.errprint(type(d))
    for key in d:
        docfield = doc.meta.get_field(key)
        val = d[key]
        if docfield:
            if docfield.reqd and (val == '' or val == None):
                frappe.msgprint(_("{0} is required").format(docfield.label),
                                raise_exception=1)

            if docfield.fieldtype == 'Select' and val and docfield.options:
                if docfield.options.startswith('link:'):
                    link_doctype = docfield.options.split(':')[1]
                    if not frappe.db.exists(link_doctype, val):
                        frappe.throw(
                            _("{0} {1} must be a valid {2}").format(
                                _(docfield.lable), val, _(link_doctype)))
                elif docfield.options == "attach_files:":
                    pass

                elif val not in docfield.options.split('\n'):
                    frappe.throw(
                        _("{0} must be one of {1}").format(
                            _(docfield.label),
                            comma_or(docfield.options.split("\n"))))

            if val and docfield.fieldtype == 'Date':
                d[key] = parse_date(val)
            elif val and docfield.fieldtype in ["Int", "Check"]:
                d[key] = cint(val)
            elif val and docfield.fieldtype in ["Currency", "Float"]:
                d[key] = flt(val)
Example #2
0
    def validate_approver(self):
        if not frappe.session.user == '*****@*****.**':
            employee = frappe.get_doc("Employee", self.employee)
            approvers = [
                l.leave_approver for l in employee.get("leave_approvers")
            ]

            if len(approvers) and self.approver not in approvers:
                frappe.throw(
                    _("Approver must be one of {0}").format(
                        comma_or(approvers)), InvalidApproverError)

            elif self.approver and not frappe.db.sql(
                    """select name from `tabHas Role`
                where parent=%s and role='Leave Approver'""", self.approver):
                frappe.throw(_("{0} ({1}) must have role 'Approver'")\
                    .format(get_fullname(self.approver), self.approver), InvalidApproverError)

            elif self.docstatus == 0 and len(
                    approvers) and self.approver != frappe.session.user:
                self.status = 'Applied'

            elif self.docstatus == 1 and len(
                    approvers) and self.approver != frappe.session.user:
                frappe.throw(
                    _("Only the selected Approver can submit this Application"
                      ), LeaveApproverIdentityError)
	def get_appr_user_role(self, det, doctype_name, total, based_on, condition, item, company):
		amt_list, appr_users, appr_roles = [], [], []
		users, roles = '',''
		if det:
			for x in det:
				amt_list.append(flt(x[0]))
			max_amount = max(amt_list)

			app_dtl = frappe.db.sql("""select approving_user, approving_role from `tabAuthorization Rule`
				where transaction = %s and (value = %s or value > %s)
				and docstatus != 2 and based_on = %s and company = %s %s""" %
				('%s', '%s', '%s', '%s', '%s', condition),
				(doctype_name, flt(max_amount), total, based_on, company))

			if not app_dtl:
				app_dtl = frappe.db.sql("""select approving_user, approving_role from `tabAuthorization Rule`
					where transaction = %s and (value = %s or value > %s) and docstatus != 2
					and based_on = %s and ifnull(company,'') = '' %s""" %
					('%s', '%s', '%s', '%s', condition), (doctype_name, flt(max_amount), total, based_on))

			for d in app_dtl:
				if(d[0]): appr_users.append(d[0])
				if(d[1]): appr_roles.append(d[1])

			if not has_common(appr_roles, frappe.get_roles()) and not has_common(appr_users, [session['user']]):
				frappe.msgprint(_("Not authroized since {0} exceeds limits").format(_(based_on)))
				frappe.throw(_("Can be approved by {0}").format(comma_or(appr_roles + appr_users)))
	def validate(self):
		"""Validate email id and check POP3/IMAP and SMTP connections is enabled."""
		if self.email_id:
			validate_email_add(self.email_id, True)

		if self.login_id_is_different:
			if not self.login_id:
				frappe.throw(_("Login Id is required"))
		else:
			self.login_id = None

		if frappe.local.flags.in_patch or frappe.local.flags.in_test:
			return

		if self.enable_incoming and not self.append_to:
			frappe.throw(_("Append To is mandatory for incoming mails"))

		if not frappe.local.flags.in_install and not frappe.local.flags.in_patch:
			if self.enable_incoming:
				self.get_pop3()

			if self.enable_outgoing:
				self.check_smtp()

		if self.notify_if_unreplied:
			if not self.send_notification_to:
				frappe.throw(_("{0} is mandatory").format(self.meta.get_label("send_notification_to")))
			for e in self.get_unreplied_notification_emails():
				validate_email_add(e, True)

		if self.enable_incoming and self.append_to:
			valid_doctypes = [d[0] for d in get_append_to()]
			if self.append_to not in valid_doctypes:
				frappe.throw(_("Append To can be one of {0}").format(comma_or(valid_doctypes)))
Example #5
0
    def validate_leave_approver(self):
        employee = frappe.get_doc("Employee", self.employee)
        leave_approvers = [
            l.leave_approver for l in employee.get("employee_leave_approvers")
        ]

        if len(leave_approvers) and self.leave_approver not in leave_approvers:
            frappe.throw(
                _("Leave approver must be one of {0}").format(
                    comma_or(leave_approvers)), InvalidLeaveApproverError)

        elif self.leave_approver and not frappe.db.sql(
                """select name from `tabUserRole`
			where parent=%s and role='Leave Approver'""", self.leave_approver):
            frappe.throw(
                _("{0} must have role 'Leave Approver'").format(
                    get_fullname(self.leave_approver)),
                InvalidLeaveApproverError)

        elif self.docstatus == 1 and len(
                leave_approvers
        ) and self.leave_approver != frappe.session.user:
            msgprint(_(
                "Only the selected Leave Approver can submit this Leave Application"
            ),
                     raise_exception=LeaveApproverIdentityError)
Example #6
0
def check_record(d):
	"""check for mandatory, select options, dates. these should ideally be in doclist"""
	from frappe.utils.dateutils import parse_date
	doc = frappe.get_doc(d)

	for key in d:
		docfield = doc.meta.get_field(key)
		val = d[key]
		if docfield:
			if docfield.reqd and (val=='' or val==None):
				frappe.msgprint(_("{0} is required").format(docfield.label), raise_exception=1)

			if docfield.fieldtype=='Select' and val and docfield.options:
				if docfield.options == "attach_files:":
					pass

				elif val not in docfield.options.split('\n'):
					frappe.throw(_("{0} must be one of {1}").format(_(docfield.label), comma_or(docfield.options.split("\n"))))

			if val and docfield.fieldtype=='Date':
				d[key] = parse_date(val)
			elif val and docfield.fieldtype in ["Int", "Check"]:
				d[key] = cint(val)
			elif val and docfield.fieldtype in ["Currency", "Float", "Percent"]:
				d[key] = flt(val)
Example #7
0
    def validate_leave_approver(self):
        employee = frappe.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 frappe.db.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)

        elif self.doc.docstatus == 1 and len(
                leave_approvers
        ) and self.doc.leave_approver != frappe.session.user:
            msgprint(_(
                "Only the selected Leave Approver can submit this Leave Application"
            ),
                     raise_exception=LeaveApproverIdentityError)
    def validate_leave_approver(self):
        employee = frappe.get_doc("Employee", self.employee)
        leave_approvers = [l.leave_approver for l in employee.get("leave_approvers")]

        if len(leave_approvers) and self.leave_approver not in leave_approvers:
            frappe.throw(
                _("Leave approver must be one of {0}").format(comma_or(leave_approvers)), InvalidLeaveApproverError
            )

        elif self.leave_approver and not frappe.db.sql(
            """select name from `tabUserRole`
			where parent=%s and role='Leave Approver'""",
            self.leave_approver,
        ):
            frappe.throw(
                _("{0} ({1}) must have role 'Leave Approver'").format(
                    get_fullname(self.leave_approver), self.leave_approver
                ),
                InvalidLeaveApproverError,
            )

        elif self.docstatus == 1 and len(leave_approvers) and self.leave_approver != frappe.session.user:
            frappe.throw(
                _("Only the selected Leave Approver can submit this Leave Application"), LeaveApproverIdentityError
            )
Example #9
0
	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 get_appr_user_role(self, det, doctype_name, total, based_on, condition, item, company):
		amt_list, appr_users, appr_roles = [], [], []
		users, roles = '',''
		if det:
			for x in det:
				amt_list.append(flt(x[0]))
			max_amount = max(amt_list)

			app_dtl = frappe.db.sql("""select approving_user, approving_role from `tabAuthorization Rule`
				where transaction = %s and (value = %s or value > %s)
				and docstatus != 2 and based_on = %s and company = %s %s""" %
				('%s', '%s', '%s', '%s', '%s', condition),
				(doctype_name, flt(max_amount), total, based_on, company))

			if not app_dtl:
				app_dtl = frappe.db.sql("""select approving_user, approving_role from `tabAuthorization Rule`
					where transaction = %s and (value = %s or value > %s) and docstatus != 2
					and based_on = %s and ifnull(company,'') = '' %s""" %
					('%s', '%s', '%s', '%s', condition), (doctype_name, flt(max_amount), total, based_on))

			for d in app_dtl:
				if(d[0]): appr_users.append(d[0])
				if(d[1]): appr_roles.append(d[1])

			if not has_common(appr_roles, frappe.user.get_roles()) and not has_common(appr_users, [session['user']]):
				frappe.msgprint(_("Not authroized since {0} exceeds limits").format(_(based_on)))
				frappe.throw(_("Can be approved by {0}").format(comma_or(appr_roles + appr_users)))
Example #11
0
def check_record(d):
    """check for mandatory, select options, dates. these should ideally be in doclist"""
    from frappe.utils.dateutils import parse_date
    doc = frappe.get_doc(d)

    for key in d:
        docfield = doc.meta.get_field(key)
        val = d[key]
        if docfield:
            if docfield.reqd and (val == '' or val == None):
                frappe.msgprint(_("{0} is required").format(docfield.label),
                                raise_exception=1)

            if docfield.fieldtype == 'Select' and val and docfield.options:
                if val not in docfield.options.split('\n'):
                    frappe.throw(
                        _("{0} must be one of {1}").format(
                            _(docfield.label),
                            comma_or(docfield.options.split("\n"))))

            if val and docfield.fieldtype == 'Date':
                d[key] = parse_date(val)
            elif val and docfield.fieldtype in ["Int", "Check"]:
                d[key] = cint(val)
            elif val and docfield.fieldtype in [
                    "Currency", "Float", "Percent"
            ]:
                d[key] = flt(val)
Example #12
0
	def validate(self):
		"""Validate email id and check POP3 and SMTP connections is enabled."""
		if self.email_id:
			validate_email_add(self.email_id, True)

		if self.login_id_is_different:
			if not self.login_id:
				frappe.throw(_("Login Id is required"))
		else:
			self.login_id = None

		if frappe.local.flags.in_patch or frappe.local.flags.in_test:
			return

		if self.enable_incoming and not self.append_to:
			frappe.throw(_("Append To is mandatory for incoming mails"))

		if not frappe.local.flags.in_install and not frappe.local.flags.in_patch:
			if self.enable_incoming:
				self.get_pop3()

			if self.enable_outgoing:
				self.check_smtp()

		if self.notify_if_unreplied:
			if not self.send_notification_to:
				frappe.throw(_("{0} is mandatory").format(self.meta.get_label("send_notification_to")))
			for e in self.get_unreplied_notification_emails():
				validate_email_add(e, True)

		if self.enable_incoming and self.append_to:
			valid_doctypes = [d[0] for d in get_append_to()]
			if self.append_to not in valid_doctypes:
				frappe.throw(_("Append To can be one of {0}").format(comma_or(valid_doctypes)))
Example #13
0
    def validate_leave_approver(self):

        employee = frappe.get_doc("Employee", self.employee)
        leave_approvers = [
            l.leave_approver for l in employee.get("leave_approvers")
        ]
        roles = frappe.get_roles(frappe.session.user)
        print roles, "******************************"
        # if frappe.session.user != self.leave_approver and "HR Manager" not in roles:
        # 	frappe.throw(_("You can not approve the Leave of the Employee"))

        if len(leave_approvers) and self.leave_approver not in leave_approvers:
            frappe.throw(
                _("Leave approver must be one of {0}").format(
                    comma_or(leave_approvers)), InvalidLeaveApproverError)

        elif self.leave_approver and not frappe.db.sql(
                """select name from `tabUserRole`
			where parent=%s and role='Leave Approver'""", self.leave_approver):
            frappe.throw(_("{0} ({1}) must have role 'Leave Approver'")\
             .format(get_fullname(self.leave_approver), self.leave_approver), InvalidLeaveApproverError)

        elif self.docstatus == 1 and len(
                leave_approvers
        ) and self.leave_approver != frappe.session.user and "HR Manager" not in roles:
            frappe.throw(
                _("Only the selected Leave Approver can submit this Leave Application"
                  ), LeaveApproverIdentityError)
Example #14
0
	def validate_purpose(self):
		valid_purposes = ["Material Issue", "Material Receipt", "Material Transfer", "Material Transfer for Manufacture",
			"Manufacture", "Repack", "Subcontract"]
		if self.purpose not in valid_purposes:
			frappe.throw(_("Purpose must be one of {0}").format(comma_or(valid_purposes)))

		if self.purpose in ("Manufacture", "Repack") and not self.difference_account:
			self.difference_account = frappe.db.get_value("Company", self.company, "default_expense_account")
 def validate_order_type(self):
     valid_types = ["Sales", "Maintenance", "Shopping Cart"]
     if not self.order_type:
         self.order_type = "Sales"
     elif self.order_type not in valid_types:
         throw(
             _("Order Type must be one of {0}").format(
                 comma_or(valid_types)))
Example #16
0
	def validate_purpose(self):
		valid_purposes = ["Material Issue", "Material Receipt", "Material Transfer", "Material Transfer for Manufacture",
			"Manufacture", "Repack", "Subcontract"]
		if self.purpose not in valid_purposes:
			frappe.throw(_("Purpose must be one of {0}").format(comma_or(valid_purposes)))

		if self.purpose in ("Manufacture", "Repack") and not self.difference_account:
			self.difference_account = frappe.db.get_value("Company", self.company, "default_expense_account")
Example #17
0
    def validate_reference_documents(self):
        if self.party_type == "Customer":
            valid_reference_doctypes = ("Sales Order", "Sales Invoice",
                                        "Journal Entry")
        elif self.party_type == "Supplier":
            valid_reference_doctypes = ("Purchase Order", "Purchase Invoice",
                                        "Journal Entry")
        elif self.party_type == "Employee":
            valid_reference_doctypes = ("Expense Claim", "Journal Entry")

        for d in self.get("references"):
            if not d.allocated_amount:
                continue
            if d.reference_doctype not in valid_reference_doctypes:
                frappe.throw(
                    _("Reference Doctype must be one of {0}").format(
                        comma_or(valid_reference_doctypes)))

            elif d.reference_name:
                if not frappe.db.exists(d.reference_doctype, d.reference_name):
                    frappe.throw(
                        _("{0} {1} does not exist").format(
                            d.reference_doctype, d.reference_name))
                else:
                    ref_doc = frappe.get_doc(d.reference_doctype,
                                             d.reference_name)

                    if d.reference_doctype != "Journal Entry":
                        if self.party != ref_doc.get(scrub(self.party_type)):
                            frappe.throw(
                                _("{0} {1} does not associated with {2} {3}").
                                format(d.reference_doctype, d.reference_name,
                                       self.party_type, self.party))
                    else:
                        self.validate_journal_entry()

                    if d.reference_doctype in ("Sales Invoice",
                                               "Purchase Invoice",
                                               "Expense Claim"):
                        if self.party_type == "Customer":
                            ref_party_account = ref_doc.debit_to
                        elif self.party_type == "Supplier":
                            ref_party_account = ref_doc.credit_to
                        elif self.party_type == "Employee":
                            ref_party_account = ref_doc.payable_account

                        if ref_party_account != self.party_account:
                            frappe.throw(
                                _("{0} {1} is associated with {2}, but Party Account is {3}"
                                  ).format(d.reference_doctype,
                                           d.reference_name, ref_party_account,
                                           self.party_account))

                    if ref_doc.docstatus != 1:
                        frappe.throw(
                            _("{0} {1} must be submitted").format(
                                d.reference_doctype, d.reference_name))
    def validate(self):
        """Validate Email Address and check POP3/IMAP and SMTP connections is enabled."""
        if self.email_id:
            validate_email_address(self.email_id, True)

        if self.login_id_is_different:
            if not self.login_id:
                frappe.throw(_("Login Id is required"))
        else:
            self.login_id = None

        duplicate_email_account = frappe.get_all("Email Account",
                                                 filters={
                                                     "email_id": self.email_id,
                                                     "name": ("!=", self.name)
                                                 })
        if duplicate_email_account:
            frappe.throw(
                _("Email ID must be unique, Email Account already exists \
				for {0}".format(frappe.bold(self.email_id))))

        if frappe.local.flags.in_patch or frappe.local.flags.in_test:
            return

        #if self.enable_incoming and not self.append_to:
        #	frappe.throw(_("Append To is mandatory for incoming mails"))

        if (not self.awaiting_password and not frappe.local.flags.in_install
                and not frappe.local.flags.in_patch):
            if self.password or self.smtp_server in ('127.0.0.1', 'localhost'):
                if self.enable_incoming:
                    self.get_incoming_server()
                    self.no_failed = 0

                if self.enable_outgoing:
                    self.check_smtp()
            else:
                if self.enable_incoming or (self.enable_outgoing and
                                            not self.no_smtp_authentication):
                    frappe.throw(
                        _("Password is required or select Awaiting Password"))

        if self.notify_if_unreplied:
            if not self.send_notification_to:
                frappe.throw(
                    _("{0} is mandatory").format(
                        self.meta.get_label("send_notification_to")))
            for e in self.get_unreplied_notification_emails():
                validate_email_address(e, True)

        if self.enable_incoming and self.append_to:
            valid_doctypes = [d[0] for d in get_append_to()]
            if self.append_to not in valid_doctypes:
                frappe.throw(
                    _("Append To can be one of {0}").format(
                        comma_or(valid_doctypes)))
Example #19
0
 def validate_purpose(self):
     valid_purposes = [
         "Material Issue", "Material Receipt", "Material Transfer",
         "Manufacture", "Repack", "Subcontract", "Sales Return",
         "Purchase Return"
     ]
     if self.purpose not in valid_purposes:
         frappe.throw(
             _("Purpose must be one of {0}").format(
                 comma_or(valid_purposes)))
Example #20
0
 def validate_purpose(self):
     valid_purposes = [
         "Material Issue",
         "Material Receipt",
         "Material Transfer",
         "Material Transfer for Manufacture",
         "Manufacture",
         "Repack",
         "Subcontract",
     ]
     if self.purpose not in valid_purposes:
         frappe.throw(_("Purpose must be one of {0}").format(comma_or(valid_purposes)))
Example #21
0
	def validate(self):
		"""Validate Email Address and check POP3/IMAP and SMTP connections is enabled."""
		if self.email_id:
			validate_email_add(self.email_id, True)

		if self.login_id_is_different:
			if not self.login_id:
				frappe.throw(_("Login Id is required"))
		else:
			self.login_id = None

		duplicate_email_account = frappe.get_all("Email Account", filters={
			"email_id": self.email_id,
			"name": ("!=", self.name)
		})
		if duplicate_email_account:
			frappe.throw(_("Email id must be unique, Email Account is already exist \
				for {0}".format(frappe.bold(self.email_id))))

		if frappe.local.flags.in_patch or frappe.local.flags.in_test:
			return

		#if self.enable_incoming and not self.append_to:
		#	frappe.throw(_("Append To is mandatory for incoming mails"))

		if (not self.awaiting_password and not frappe.local.flags.in_install
			and not frappe.local.flags.in_patch):
			if self.password or self.smtp_server in ('127.0.0.1', 'localhost'):
				if self.enable_incoming:
					self.get_incoming_server()
					self.no_failed = 0


				if self.enable_outgoing:
					self.check_smtp()
			else:
				if self.enable_incoming or self.enable_outgoing:
					frappe.throw(_("Password is required or select Awaiting Password"))

		if self.notify_if_unreplied:
			if not self.send_notification_to:
				frappe.throw(_("{0} is mandatory").format(self.meta.get_label("send_notification_to")))
			for e in self.get_unreplied_notification_emails():
				validate_email_add(e, True)

		if self.enable_incoming and self.append_to:
			valid_doctypes = [d[0] for d in get_append_to()]
			if self.append_to not in valid_doctypes:
				frappe.throw(_("Append To can be one of {0}").format(comma_or(valid_doctypes)))
Example #22
0
	def validate_reference_documents(self):
		if self.party_type == "Student":
			valid_reference_doctypes = ("Fees")
		elif self.party_type == "Customer":
			valid_reference_doctypes = ("Sales Order", "Sales Invoice", "Journal Entry")
		elif self.party_type == "Supplier":
			valid_reference_doctypes = ("Purchase Order", "Purchase Invoice", "Journal Entry")
		elif self.party_type == "Employee":
			valid_reference_doctypes = ("Expense Claim", "Journal Entry", "Employee Advance")

		for d in self.get("references"):
			if not d.allocated_amount:
				continue
			if d.reference_doctype not in valid_reference_doctypes:
				frappe.throw(_("Reference Doctype must be one of {0}")
					.format(comma_or(valid_reference_doctypes)))

			elif d.reference_name:
				if not frappe.db.exists(d.reference_doctype, d.reference_name):
					frappe.throw(_("{0} {1} does not exist").format(d.reference_doctype, d.reference_name))
				else:
					ref_doc = frappe.get_doc(d.reference_doctype, d.reference_name)

					if d.reference_doctype != "Journal Entry":
						if self.party != ref_doc.get(scrub(self.party_type)):
							frappe.throw(_("{0} {1} is not associated with {2} {3}")
								.format(d.reference_doctype, d.reference_name, self.party_type, self.party))
					else:
						self.validate_journal_entry()

					if d.reference_doctype in ("Sales Invoice", "Purchase Invoice", "Expense Claim", "Fees"):
						if self.party_type == "Customer":
							ref_party_account = ref_doc.debit_to
						elif self.party_type == "Student":
							ref_party_account = ref_doc.receivable_account
						elif self.party_type=="Supplier":
							ref_party_account = ref_doc.credit_to
						elif self.party_type=="Employee":
							ref_party_account = ref_doc.payable_account

						if ref_party_account != self.party_account:
								frappe.throw(_("{0} {1} is associated with {2}, but Party Account is {3}")
									.format(d.reference_doctype, d.reference_name, ref_party_account, self.party_account))

					if ref_doc.docstatus != 1:
						frappe.throw(_("{0} {1} must be submitted")
							.format(d.reference_doctype, d.reference_name))
Example #23
0
    def validate_leave_approver(self):
        employee = frappe.get_doc("Employee", self.employee)
        leave_approvers = [
            frappe.db.get_value("Employee", employee.reports_to, "user_id")
        ]

        if len(leave_approvers) and self.leave_approver not in leave_approvers:
            frappe.throw(
                _("Leave approver must be one of {0}").format(
                    comma_or(leave_approvers)), InvalidLeaveApproverError)

        elif self.leave_approver and not frappe.db.sql(
                """select name from `tabUserRole`
			where parent=%s and role='Leave Approver'""", self.leave_approver):
            frappe.throw(_("{0} ({1}) must have role 'Leave Approver'")\
             .format(get_fullname(self.leave_approver), self.leave_approver), InvalidLeaveApproverError)

        elif self.docstatus == 1 and len(
                leave_approvers
        ) and self.leave_approver != frappe.session.user:
            frappe.throw(
                _("Only the selected Leave Approver can submit this Leave Application"
                  ), LeaveApproverIdentityError)
Example #24
0
	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)
Example #25
0
def validate_account_type(account, account_types):
	account_type = frappe.db.get_value("Account", account, "account_type")
	if account_type not in account_types:
		frappe.throw(_("Account Type for {0} must be {1}").format(account, comma_or(account_types)))
Example #26
0
def validate_status(status, options):
    if status not in options:
        frappe.throw(_("Status must be one of {0}").format(comma_or(options)))
Example #27
0
	def validate_order_type(self):
		valid_types = ["Sales", "Maintenance", "Shopping Cart"]
		if not self.order_type:
			self.order_type = "Sales"
		elif self.order_type not in valid_types:
			throw(_("Order Type must be one of {0}").format(comma_or(valid_types)))
Example #28
0
def validate_status(status, options):
	if status not in options:
		frappe.throw(_("Status must be one of {0}").format(comma_or(options)))
Example #29
0
def validate_status(status, options):
	if status not in options:
		msgprint(_("Status must be one of ") + comma_or(options), raise_exception=True)
Example #30
0
	def validate_account_type(self, account, account_types):
		account_type = frappe.db.get_value("Account", account, "account_type")
		if account_type not in account_types:
			frappe.throw(_("Account Type for {0} must be {1}").format(account, comma_or(account_types)))