Update quoted_item_comparison.py

This commit is contained in:
Nabin Hait 2016-12-09 12:17:45 +05:30 committed by GitHub
parent 5c031a3512
commit 8e885163a3

View File

@ -3,11 +3,9 @@
from __future__ import unicode_literals
from erpnext.setup.utils import get_exchange_rate
import frappe
def execute(filters=None):
qty_list = get_quantity_list(filters.item)
data = get_quote_list(filters.item, qty_list)
@ -15,12 +13,9 @@ def execute(filters=None):
columns = get_columns(qty_list)
return columns, data
def get_quote_list(item, qty_list):
out = []
if item:
price_data = []
suppliers = []
@ -38,11 +33,11 @@ def get_quote_list(item, qty_list):
#Add a row for each supplier
for root in set(suppliers):
supplier_currency = frappe.db.get_value("Supplier",root,"default_currency")
supplier_currency = frappe.db.get_value("Supplier", root, "default_currency")
if supplier_currency:
exg = get_exchange_rate(supplier_currency,company_currency)
exchange_rate = get_exchange_rate(supplier_currency, company_currency)
else:
exg = 1
exchange_rate = 1
row = frappe._dict({
"supplier_name": root
@ -51,7 +46,7 @@ def get_quote_list(item, qty_list):
# Get the quantity for this row
for item_price in price_data:
if str(item_price.qty) == col.key and item_price.supplier == root:
row[col.key] = item_price.rate * exg
row[col.key] = item_price.rate * exchange_rate
row[col.key + "QUOTE"] = item_price.parent
break
else:
@ -59,15 +54,11 @@ def get_quote_list(item, qty_list):
row[col.key + "QUOTE"] = ""
out.append(row)
return out
def get_quantity_list(item):
out = []
if item:
qty_list = frappe.db.sql("""select distinct qty from `tabSupplier Quotation Item` where ifnull(item_code,'')=%s and docstatus < 2""", item, as_dict=1)
qty_list.sort(reverse=False)
@ -105,5 +96,4 @@ def get_columns(qty_list):
"width": 90
})
return columns
return columns