diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.py b/erpnext/accounts/doctype/pos_profile/pos_profile.py index acf9161f16c..36932b9424e 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.py @@ -289,6 +289,11 @@ def pos_profile_query(doctype: str, txt: str, searchfield: str, start: int, page user = frappe.session["user"] company = filters.get("company") or frappe.defaults.get_user_default("company") + allowed_pos_profiles = frappe.get_list("POS Profile", pluck="name") + + if not allowed_pos_profiles: + return {} + pf = frappe.qb.DocType("POS Profile") pfu = frappe.qb.DocType("POS Profile User") @@ -298,6 +303,7 @@ def pos_profile_query(doctype: str, txt: str, searchfield: str, start: int, page .on(pfu.parent == pf.name) .select(pf.name) .where((pfu.user == user) & (pf.company == company) & pf.name.like(f"%{txt}%") & (pf.disabled == 0)) + .where(pf.name.isin(allowed_pos_profiles)) .limit(page_len) .offset(start) .run() @@ -314,6 +320,7 @@ def pos_profile_query(doctype: str, txt: str, searchfield: str, start: int, page & (pf.company == company) & pf.name.like(f"%{txt}%") & (pf.disabled == 0) + & (pf.name.isin(allowed_pos_profiles)) ) .run() ) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 4556b3defff..bbe5ef8ba5a 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -1551,6 +1551,11 @@ def get_pos_profile(company: str, pos_profile: str | None = None, user: str | No if not user: user = frappe.session["user"] + allowed_pos_profiles = frappe.get_list("POS Profile", pluck="name") + + if not allowed_pos_profiles: + return None + pf = frappe.qb.DocType("POS Profile") pfu = frappe.qb.DocType("POS Profile User") @@ -1560,6 +1565,7 @@ def get_pos_profile(company: str, pos_profile: str | None = None, user: str | No .on(pf.name == pfu.parent) .select(pf.star) .where((pfu.user == user) & (pfu.default == 1)) + .where(pf.name.isin(allowed_pos_profiles)) ) if company: @@ -1574,6 +1580,7 @@ def get_pos_profile(company: str, pos_profile: str | None = None, user: str | No .on(pf.name == pfu.parent) .select(pf.star) .where((pf.company == company) & (pf.disabled == 0)) + .where(pf.name.isin(allowed_pos_profiles)) ).run(as_dict=True) return pos_profile and pos_profile[0] or None