From 5c51145984daa8c6371da53dc5f47c2b86923e82 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sun, 31 May 2026 09:45:28 +0000 Subject: [PATCH] refactor(pos_profile): migrating raw sql to qb in set_defaults (backport #55447) (#55450) Co-authored-by: Diptanil Saha --- .../accounts/doctype/pos_profile/pos_profile.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.py b/erpnext/accounts/doctype/pos_profile/pos_profile.py index b8988687486..af8e9b96fd5 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.py @@ -208,15 +208,14 @@ class POSProfile(Document): def set_defaults(self, include_current_pos=True): frappe.defaults.clear_default("is_pos") - if not include_current_pos: - condition = " where pfu.name != '%s' and pfu.default = 1 " % self.name.replace("'", "'") - else: - condition = " where pfu.default = 1 " + pfu = frappe.qb.DocType("POS Profile User") - pos_view_users = frappe.db.sql_list( - f"""select pfu.user - from `tabPOS Profile User` as pfu {condition}""" - ) + query = frappe.qb.from_(pfu).select(pfu.user).where(pfu.default == 1) + + if not include_current_pos: + query = query.where(pfu.name != self.name) + + pos_view_users = query.run(as_list=1, pluck=True) for user in pos_view_users: if user: