fix(accounts): set pos profile on invoices respecting user permissions (#58508)

This commit is contained in:
Diptanil Saha
2026-08-27 22:06:36 +05:30
committed by GitHub
parent e95ca2444c
commit 9018573179
2 changed files with 14 additions and 0 deletions

View File

@@ -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()
)

View File

@@ -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