optimize(various)

This commit is contained in:
Rushabh Mehta
2018-08-08 16:37:31 +05:30
parent 4d0b8da0e5
commit 708e47aadf
90 changed files with 254 additions and 250 deletions

View File

@@ -20,10 +20,10 @@ def get_qty_in_stock(item_code, item_warehouse_field, warehouse=None):
if warehouse:
stock_qty = frappe.db.sql("""
select GREATEST(S.actual_qty - S.reserved_qty - S.reserved_qty_for_production - S.reserved_qty_for_sub_contract, 0) / IFNULL(C.conversion_factor, 1)
select GREATEST(S.actual_qty - S.reserved_qty - S.reserved_qty_for_production - S.reserved_qty_for_sub_contract, 0) / IFNULL(C.conversion_factor, 1)
from tabBin S
inner join `tabItem` I on S.item_code = I.Item_code
left join `tabUOM Conversion Detail` C on I.sales_uom = C.uom and C.parent = I.Item_code
left join `tabUOM Conversion Detail` C on I.sales_uom = C.uom and C.parent = I.Item_code
where S.item_code=%s and S.warehouse=%s""", (item_code, warehouse))
if stock_qty:
@@ -37,7 +37,7 @@ def adjust_qty_for_expired_items(item_code, stock_qty, warehouse):
batches = frappe.get_all('Batch', filters=[{'item': item_code}], fields=['expiry_date', 'name'])
expired_batches = get_expired_batches(batches)
stock_qty = [list(item) for item in stock_qty]
for batch in expired_batches:
if warehouse:
stock_qty[0][0] = max(0, stock_qty[0][0] - get_batch_qty(batch, warehouse))
@@ -103,7 +103,7 @@ def get_price(item_code, price_list, customer_group, company, qty=1):
price_obj["formatted_price"] = fmt_money(price_obj["price_list_rate"], currency=price_obj["currency"])
price_obj["currency_symbol"] = not cint(frappe.db.get_default("hide_currency_symbol")) \
and (frappe.db.get_value("Currency", price_obj.currency, "symbol") or price_obj.currency) \
and (frappe.db.get_value("Currency", price_obj.currency, "symbol", cache=True) or price_obj.currency) \
or ""
uom_conversion_factor = frappe.db.sql("""select C.conversion_factor