[fix] pull source warehouse from production order child table (#11718)
This commit is contained in:
parent
e3d6d21ec5
commit
9d0092f89a
@ -15,12 +15,12 @@ def get_item_list(prod_list, filters):
|
|||||||
out = []
|
out = []
|
||||||
|
|
||||||
#Add a row for each item/qty
|
#Add a row for each item/qty
|
||||||
for prod_order in prod_list:
|
for prod_details in prod_list:
|
||||||
prod_details = frappe.db.get_value("Production Order", prod_order.name,
|
|
||||||
["bom_no", "source_warehouse", "qty", "produced_qty"], as_dict=1)
|
|
||||||
|
|
||||||
desc = frappe.db.get_value("BOM", prod_details.bom_no, "description")
|
desc = frappe.db.get_value("BOM", prod_details.bom_no, "description")
|
||||||
|
|
||||||
|
for prod_item_details in frappe.db.get_values("Production Order Item",
|
||||||
|
{"parent": prod_details.name}, ["item_code", "source_warehouse"], as_dict=1):
|
||||||
|
|
||||||
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,
|
||||||
ifnull(ledger.actual_qty*bom.quantity/bom_item.stock_qty,0) as build_qty
|
ifnull(ledger.actual_qty*bom.quantity/bom_item.stock_qty,0) as build_qty
|
||||||
@ -31,11 +31,12 @@ def get_item_list(prod_list, filters):
|
|||||||
AND ledger.warehouse = ifnull(%(warehouse)s,%(filterhouse)s)
|
AND ledger.warehouse = ifnull(%(warehouse)s,%(filterhouse)s)
|
||||||
WHERE
|
WHERE
|
||||||
bom.name = bom_item.parent
|
bom.name = bom_item.parent
|
||||||
|
and bom_item.item_code = %(item_code)s
|
||||||
and bom.name = %(bom)s
|
and bom.name = %(bom)s
|
||||||
GROUP BY
|
GROUP BY
|
||||||
bom_item.item_code""",
|
bom_item.item_code""",
|
||||||
{"bom": prod_details.bom_no, "warehouse": prod_details.source_warehouse,
|
{"bom": prod_details.bom_no, "warehouse": prod_item_details.source_warehouse,
|
||||||
"filterhouse": filters.warehouse}, as_dict=1)
|
"filterhouse": filters.warehouse, "item_code": prod_item_details.item_code}, as_dict=1)
|
||||||
|
|
||||||
stock_qty = 0
|
stock_qty = 0
|
||||||
count = 0
|
count = 0
|
||||||
@ -53,11 +54,13 @@ def get_item_list(prod_list, filters):
|
|||||||
build = "N"
|
build = "N"
|
||||||
|
|
||||||
row = frappe._dict({
|
row = frappe._dict({
|
||||||
"production_order": prod_order.name,
|
"production_order": prod_details.name,
|
||||||
"status": prod_order.status,
|
"status": prod_details.status,
|
||||||
"req_items": cint(count),
|
"req_items": cint(count),
|
||||||
"instock": stock_qty,
|
"instock": stock_qty,
|
||||||
"description": desc,
|
"description": desc,
|
||||||
|
"source_warehouse": prod_item_details.source_warehouse,
|
||||||
|
"item_code": prod_item_details.item_code,
|
||||||
"bom_no": prod_details.bom_no,
|
"bom_no": prod_details.bom_no,
|
||||||
"qty": prod_details.qty,
|
"qty": prod_details.qty,
|
||||||
"buildable_qty": buildable_qty,
|
"buildable_qty": buildable_qty,
|
||||||
@ -69,8 +72,9 @@ def get_item_list(prod_list, filters):
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
def get_production_orders():
|
def get_production_orders():
|
||||||
|
out = frappe.get_all("Production Order", filters={"docstatus": 1, "status": ( "!=","Completed")},
|
||||||
|
fields=["name","status", "bom_no", "qty", "produced_qty"], order_by='name')
|
||||||
|
|
||||||
out = frappe.get_all("Production Order", filters={"docstatus": 1, "status": ( "!=","Completed")}, fields=["name","status"], order_by='name')
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def get_columns():
|
def get_columns():
|
||||||
@ -93,6 +97,18 @@ def get_columns():
|
|||||||
"options": "",
|
"options": "",
|
||||||
"width": 230
|
"width": 230
|
||||||
}, {
|
}, {
|
||||||
|
"fieldname": "item_code",
|
||||||
|
"label": "Item Code",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Item",
|
||||||
|
"width": 110
|
||||||
|
},{
|
||||||
|
"fieldname": "source_warehouse",
|
||||||
|
"label": "Source Warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Warehouse",
|
||||||
|
"width": 110
|
||||||
|
},{
|
||||||
"fieldname": "qty",
|
"fieldname": "qty",
|
||||||
"label": "Qty to Build",
|
"label": "Qty to Build",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user