From 925f39e81989a11e8534f371f5964acb8e3aae96 Mon Sep 17 00:00:00 2001 From: Diptanil Saha Date: Sun, 31 May 2026 14:54:55 +0530 Subject: [PATCH] refactor(pos_profile): migrating raw sql to qb in set_defaults (#55447) --- .../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 7a51edfb169..39a7694850a 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.py @@ -209,15 +209,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: