mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-09 23:39:28 +00:00
Co-authored-by: Diptanil Saha <diptanil@frappe.io>
This commit is contained in:
@@ -271,40 +271,40 @@ 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")
|
||||||
|
|
||||||
args = {
|
allowed_pos_profiles = frappe.get_list("POS Profile", pluck="name")
|
||||||
"user": user,
|
|
||||||
"start": start,
|
|
||||||
"company": company,
|
|
||||||
"page_len": page_len,
|
|
||||||
"txt": "%%%s%%" % txt,
|
|
||||||
}
|
|
||||||
|
|
||||||
pos_profile = frappe.db.sql(
|
if not allowed_pos_profiles:
|
||||||
"""select pf.name
|
return {}
|
||||||
from
|
|
||||||
`tabPOS Profile` pf, `tabPOS Profile User` pfu
|
pf = frappe.qb.DocType("POS Profile")
|
||||||
where
|
pfu = frappe.qb.DocType("POS Profile User")
|
||||||
pfu.parent = pf.name and pfu.user = %(user)s and pf.company = %(company)s
|
|
||||||
and (pf.name like %(txt)s)
|
pos_profile = (
|
||||||
and pf.disabled = 0 limit %(page_len)s offset %(start)s""",
|
frappe.qb.from_(pf)
|
||||||
args,
|
.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:
|
if not pos_profile:
|
||||||
del args["user"]
|
pos_profile = (
|
||||||
|
frappe.qb.from_(pf)
|
||||||
pos_profile = frappe.db.sql(
|
.left_join(pfu)
|
||||||
"""select pf.name
|
.on(pf.name == pfu.parent)
|
||||||
from
|
.select(pf.name)
|
||||||
`tabPOS Profile` pf left join `tabPOS Profile User` pfu
|
.where(
|
||||||
on
|
(pfu.user.isnull() | (pfu.user == ""))
|
||||||
pf.name = pfu.parent
|
& (pf.company == company)
|
||||||
where
|
& pf.name.like(f"%{txt}%")
|
||||||
ifnull(pfu.user, '') = ''
|
& (pf.disabled == 0)
|
||||||
and pf.company = %(company)s
|
& (pf.name.isin(allowed_pos_profiles))
|
||||||
and pf.name like %(txt)s
|
)
|
||||||
and pf.disabled = 0""",
|
.run()
|
||||||
args,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return pos_profile
|
return pos_profile
|
||||||
|
|||||||
@@ -1418,6 +1418,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")
|
||||||
|
|
||||||
@@ -1427,6 +1432,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:
|
||||||
@@ -1441,6 +1447,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