mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-16 19:24:21 +00:00
feat(pos): prevent disabling POS Profile when open POS sessions exist
(cherry picked from commit c5219278fb)
This commit is contained in:
@@ -70,6 +70,7 @@ class POSProfile(Document):
|
||||
# end: auto-generated types
|
||||
|
||||
def validate(self):
|
||||
self.validate_disabled()
|
||||
self.validate_default_profile()
|
||||
self.validate_all_link_fields()
|
||||
self.validate_duplicate_groups()
|
||||
@@ -94,6 +95,21 @@ class POSProfile(Document):
|
||||
title=_("Mandatory Accounting Dimension"),
|
||||
)
|
||||
|
||||
def validate_disabled(self):
|
||||
old_doc = self.get_doc_before_save()
|
||||
|
||||
if (
|
||||
old_doc
|
||||
and self.disabled
|
||||
and old_doc.disabled != self.disabled
|
||||
and frappe.db.exists("POS Opening Entry", {"pos_profile": self.name, "status": "Open"})
|
||||
):
|
||||
frappe.throw(
|
||||
_("POS Profile {0} cannot be disabled as there are ongoing POS sessions.").format(
|
||||
frappe.bold(self.name)
|
||||
)
|
||||
)
|
||||
|
||||
def validate_default_profile(self):
|
||||
for row in self.applicable_for_users:
|
||||
res = frappe.db.sql(
|
||||
|
||||
Reference in New Issue
Block a user