mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-20 03:47:11 +00:00
fix(accounts): set pos profile on invoices respecting user permissions (#58508)
(cherry picked from commit 9018573179)
# Conflicts:
# erpnext/accounts/doctype/pos_profile/pos_profile.py
This commit is contained in:
@@ -280,6 +280,7 @@ def pos_profile_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
user = frappe.session["user"]
|
user = frappe.session["user"]
|
||||||
company = filters.get("company") or frappe.defaults.get_user_default("company")
|
company = filters.get("company") or frappe.defaults.get_user_default("company")
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
args = {
|
args = {
|
||||||
"user": user,
|
"user": user,
|
||||||
"start": start,
|
"start": start,
|
||||||
@@ -314,6 +315,42 @@ def pos_profile_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
and pf.name like %(txt)s
|
and pf.name like %(txt)s
|
||||||
and pf.disabled = 0""",
|
and pf.disabled = 0""",
|
||||||
args,
|
args,
|
||||||
|
=======
|
||||||
|
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")
|
||||||
|
|
||||||
|
pos_profile = (
|
||||||
|
frappe.qb.from_(pf)
|
||||||
|
.inner_join(pfu)
|
||||||
|
.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()
|
||||||
|
)
|
||||||
|
|
||||||
|
if not pos_profile:
|
||||||
|
pos_profile = (
|
||||||
|
frappe.qb.from_(pf)
|
||||||
|
.left_join(pfu)
|
||||||
|
.on(pf.name == pfu.parent)
|
||||||
|
.select(pf.name)
|
||||||
|
.where(
|
||||||
|
(pfu.user.isnull() | (pfu.user == ""))
|
||||||
|
& (pf.company == company)
|
||||||
|
& pf.name.like(f"%{txt}%")
|
||||||
|
& (pf.disabled == 0)
|
||||||
|
& (pf.name.isin(allowed_pos_profiles))
|
||||||
|
)
|
||||||
|
.run()
|
||||||
|
>>>>>>> 9018573 (fix(accounts): set pos profile on invoices respecting user permissions (#58508))
|
||||||
)
|
)
|
||||||
|
|
||||||
return pos_profile
|
return pos_profile
|
||||||
|
|||||||
@@ -1522,6 +1522,11 @@ def get_pos_profile(company, pos_profile=None, user=None):
|
|||||||
if not user:
|
if not user:
|
||||||
user = frappe.session["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")
|
pf = frappe.qb.DocType("POS Profile")
|
||||||
pfu = frappe.qb.DocType("POS Profile User")
|
pfu = frappe.qb.DocType("POS Profile User")
|
||||||
|
|
||||||
@@ -1531,6 +1536,7 @@ def get_pos_profile(company, pos_profile=None, user=None):
|
|||||||
.on(pf.name == pfu.parent)
|
.on(pf.name == pfu.parent)
|
||||||
.select(pf.star)
|
.select(pf.star)
|
||||||
.where((pfu.user == user) & (pfu.default == 1))
|
.where((pfu.user == user) & (pfu.default == 1))
|
||||||
|
.where(pf.name.isin(allowed_pos_profiles))
|
||||||
)
|
)
|
||||||
|
|
||||||
if company:
|
if company:
|
||||||
@@ -1545,6 +1551,7 @@ def get_pos_profile(company, pos_profile=None, user=None):
|
|||||||
.on(pf.name == pfu.parent)
|
.on(pf.name == pfu.parent)
|
||||||
.select(pf.star)
|
.select(pf.star)
|
||||||
.where((pf.company == company) & (pf.disabled == 0))
|
.where((pf.company == company) & (pf.disabled == 0))
|
||||||
|
.where(pf.name.isin(allowed_pos_profiles))
|
||||||
).run(as_dict=True)
|
).run(as_dict=True)
|
||||||
|
|
||||||
return pos_profile and pos_profile[0] or None
|
return pos_profile and pos_profile[0] or None
|
||||||
|
|||||||
Reference in New Issue
Block a user