Custom exception class for validation errors when allowances are exceeded in POS retail status management.
import frappe
from frappe.utils import comma_or, nowdate, getdate
from frappe import _
from frappe.model.document import Document
class OverAllowanceError(frappe.ValidationError): pass
def validate_status(status, options):
if status not in options:
frappe.throw(_("Status must be one of {0}").format(comma_or(options)))
status_map = {
"POS Opening Shift": [
["Draft", None],
["Open", "eval:self.docstatus == 1 and not self.pos_closing_shift"],
["Closed", "eval:self.docstatus == 1 and self.pos_closing_shift"],
["Cancelled", "eval:self.docstatus == 2"],
]
}
class StatusUpdater(Document):
def set_status(self, update=False, status=None, update_modified=True):
if self.is_new():
if self.get('amended_from'):
self.status = 'Draft'
return
if self.doctype in status_map:
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key