From 2e01573a40571b90be066ab87e2706d7e132c258 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 30 Oct 2019 16:22:30 +0530 Subject: [PATCH 1/2] fix: item price stock report not working --- erpnext/stock/report/item_price_stock/item_price_stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/report/item_price_stock/item_price_stock.py b/erpnext/stock/report/item_price_stock/item_price_stock.py index e539aff59c8..a0783da3aae 100644 --- a/erpnext/stock/report/item_price_stock/item_price_stock.py +++ b/erpnext/stock/report/item_price_stock/item_price_stock.py @@ -89,7 +89,7 @@ def get_item_price_qty_data(filters): {conditions}""" .format(conditions=conditions), filters, as_dict=1) - price_list_names = list(set([frappe.db.escape(item.price_list_name) for item in item_results])) + price_list_names = list(set([item.price_list_name for item in item_results])) buying_price_map = get_price_map(price_list_names, buying=1) selling_price_map = get_price_map(price_list_names, selling=1) From d8b64cd19963978c8ced612e4b23a6a87cf3b4e8 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 30 Oct 2019 16:27:58 +0530 Subject: [PATCH 2/2] replaced frappe.db.sql with frappe.get_all --- .../item_price_stock/item_price_stock.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/erpnext/stock/report/item_price_stock/item_price_stock.py b/erpnext/stock/report/item_price_stock/item_price_stock.py index a0783da3aae..5296211fae8 100644 --- a/erpnext/stock/report/item_price_stock/item_price_stock.py +++ b/erpnext/stock/report/item_price_stock/item_price_stock.py @@ -129,17 +129,15 @@ def get_price_map(price_list_names, buying=0, selling=0): rate_key = "Buying Rate" if buying else "Selling Rate" price_list_key = "Buying Price List" if buying else "Selling Price List" - price_list_condition = " and buying=1" if buying else " and selling=1" - pricing_details = frappe.db.sql(""" - select - name,price_list,price_list_rate - from - `tabItem Price` - where - name in ({price_list_names}) {price_list_condition} - """.format(price_list_names=', '.join(['%s']*len(price_list_names)), - price_list_condition=price_list_condition), price_list_names, as_dict=1) + filters = {"name": ("in", price_list_names)} + if buying: + filters["buying"] = 1 + else: + filters["selling"] = 1 + + pricing_details = frappe.get_all("Item Price", + fields = ["name", "price_list", "price_list_rate"], filters=filters) for d in pricing_details: name = d["name"]