mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-27 22:05:19 +00:00
fix(accounts): set pos profile on invoices respecting user permissions (#58508)
This commit is contained in:
@@ -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()
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user