From 1eb098caf9d9a793d4568686156fffd6eacca9b2 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Wed, 21 Nov 2018 14:36:58 +0530 Subject: [PATCH] Add additional condition condition to get_pos_profile - If we have any POS Profile related to the user, that profile should be used --- erpnext/stock/get_item_details.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index d90db56e2c..01ee9db1ca 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -594,22 +594,21 @@ def get_pos_profile(company, pos_profile=None, user=None): if not user: user = frappe.session['user'] - pos_profile = frappe.db.sql("""select pf.* - from - `tabPOS Profile` pf, `tabPOS Profile User` pfu - where - pfu.parent = pf.name and pfu.user = %s and pf.company = %s - and pf.disabled = 0 and pfu.default=1""", (user, company), as_dict=1) - - if not pos_profile: - pos_profile = frappe.db.sql("""select pf.* - from - `tabPOS Profile` pf left join `tabPOS Profile User` pfu - on + pos_profile = frappe.db.sql("""SELECT pf.* + FROM + `tabPOS Profile` pf LEFT JOIN `tabPOS Profile User` pfu + ON pf.name = pfu.parent - where - ifnull(pfu.user, '') = '' and pf.company = %s - and pf.disabled = 0""", (company), as_dict=1) + WHERE + ( + (pfu.user = %(user)s AND pf.company = %(company)s AND pfu.default=1) + OR (pfu.user = %(user)s AND pfu.default=1) + OR (ifnull(pfu.user, '') = '' AND pf.company = %(company)s) + ) AND pf.disabled = 0 + """, { + 'user': user, + 'company': company + }, as_dict=1) return pos_profile and pos_profile[0] or None