mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 07:02:54 +00:00
Fixed code issues
Also changed qty to Quantity left to build
This commit is contained in:
@@ -17,49 +17,49 @@ def get_item_list(prod_list, filters):
|
|||||||
low_price_data = []
|
low_price_data = []
|
||||||
low_supplier = []
|
low_supplier = []
|
||||||
|
|
||||||
# Get the default supplier of suppliers
|
|
||||||
#Add a row for each item/qty
|
#Add a row for each item/qty
|
||||||
for root in prod_list:
|
for prod_order in prod_list:
|
||||||
bom = frappe.db.get_value("Production Order", root.name,"bom_no")
|
bom = frappe.db.get_value("Production Order", prod_order.name, "bom_no")
|
||||||
warehouse = frappe.db.get_value("Production Order", root.name,"source_warehouse")
|
warehouse = frappe.db.get_value("Production Order", prod_order.name, "source_warehouse")
|
||||||
warehouse = "Stores - VMI"
|
|
||||||
desc = frappe.db.get_value("BOM", bom, "description")
|
desc = frappe.db.get_value("BOM", bom, "description")
|
||||||
qty = frappe.db.get_value("Production Order", root.name,"qty")
|
qty = frappe.db.get_value("Production Order", prod_order.name, "qty")
|
||||||
|
produced_value = frappe.db.get_value("Production Order", prod_order.name, "produced_qty")
|
||||||
item_list = frappe.db.sql("""SELECT
|
item_list = frappe.db.sql("""SELECT
|
||||||
bom_item.item_code as item_code,
|
bom_item.item_code as item_code,
|
||||||
SUM(ifnull(ledger.actual_qty * conf_ledger.conversion_factor,0))/(bom_item.qty * conf_item.conversion_factor) as build_qty
|
ifnull(ledger.actual_qty,0)/(bom_item.qty) as build_qty
|
||||||
FROM
|
FROM
|
||||||
`tabBOM Item` AS bom_item
|
`tabBOM Item` AS bom_item
|
||||||
LEFT JOIN `tabBin` AS ledger
|
LEFT JOIN `tabBin` AS ledger
|
||||||
ON bom_item.item_code = ledger.item_code AND ledger.warehouse = ifnull(%(warehouse)s,%(filterhouse)s)
|
ON bom_item.item_code = ledger.item_code
|
||||||
LEFT JOIN `tabUOM Conversion Detail` AS conf_item
|
AND ledger.warehouse = ifnull(%(warehouse)s,%(filterhouse)s)
|
||||||
ON conf_item.parent = bom_item.item_code AND conf_item.uom = bom_item.stock_uom
|
|
||||||
LEFT JOIN `tabUOM Conversion Detail` AS conf_ledger
|
|
||||||
ON conf_ledger.parent = ledger.item_code AND conf_ledger.uom = ledger.stock_uom
|
|
||||||
WHERE
|
WHERE
|
||||||
bom_item.parent = %(bom)s
|
bom_item.parent = %(bom)s
|
||||||
GROUP BY
|
GROUP BY
|
||||||
bom_item.item_code""", {"bom": bom, "warehouse": warehouse, "filterhouse": filters.warehouse}, as_dict=1)
|
bom_item.item_code""", {"bom": bom, "warehouse": warehouse, "filterhouse": filters.warehouse}, as_dict=1)
|
||||||
stock_qty = 0
|
stock_qty = 0
|
||||||
count = 0
|
count = 0
|
||||||
|
buildable_qty = qty
|
||||||
for item in item_list:
|
for item in item_list:
|
||||||
count = count + 1
|
count = count + 1
|
||||||
if item.build_qty >= qty:
|
if item.build_qty >= (qty-produced_value):
|
||||||
stock_qty = stock_qty + 1
|
stock_qty = stock_qty + 1
|
||||||
|
elif buildable_qty > item.build_qty:
|
||||||
|
buidable_qty = item.build_qty
|
||||||
|
|
||||||
if count == stock_qty:
|
if count == stock_qty:
|
||||||
build = "Y"
|
build = "Y"
|
||||||
else:
|
else:
|
||||||
build = "N"
|
build = "N"
|
||||||
|
|
||||||
row = frappe._dict({
|
row = frappe._dict({
|
||||||
"production_order": root.name,
|
"production_order": prod_order.name,
|
||||||
"status": root.status,
|
"status": prod_order.status,
|
||||||
"req_items": cint(count),
|
"req_items": cint(count),
|
||||||
"instock": stock_qty,
|
"instock": stock_qty,
|
||||||
"description": desc,
|
"description": desc,
|
||||||
"bom_no": bom,
|
"bom_no": bom,
|
||||||
"qty": qty,
|
"qty": qty,
|
||||||
|
"buildable_qty": buildable_qty,
|
||||||
"ready_to_build": build
|
"ready_to_build": build
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -69,16 +69,7 @@ def get_item_list(prod_list, filters):
|
|||||||
|
|
||||||
def get_production_orders():
|
def get_production_orders():
|
||||||
|
|
||||||
#out = []
|
|
||||||
|
|
||||||
|
|
||||||
#prod_list = frappe.db.sql("""select name, status from `tabProduction Order` as prod where status != "Completed" and docstatus = 1""", {}, as_dict=1)
|
|
||||||
out = frappe.get_all("Production Order", filters={"docstatus": 1, "status": ( "!=","Completed")}, fields=["name","status"], order_by='name')
|
out = frappe.get_all("Production Order", filters={"docstatus": 1, "status": ( "!=","Completed")}, fields=["name","status"], order_by='name')
|
||||||
#prod_list.sort(reverse=False)
|
|
||||||
|
|
||||||
#for po in prod_list:
|
|
||||||
#out.append(po)
|
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def get_columns():
|
def get_columns():
|
||||||
|
|||||||
Reference in New Issue
Block a user