mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 08:24:47 +00:00
Fetch BOM items in Production Order in the same order as BOM
This commit is contained in:
@@ -512,7 +512,6 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite
|
|||||||
|
|
||||||
# Did not use qty_consumed_per_unit in the query, as it leads to rounding loss
|
# Did not use qty_consumed_per_unit in the query, as it leads to rounding loss
|
||||||
query = """select
|
query = """select
|
||||||
(Select idx from `tabBOM Item` where item_code = bom_item.item_code and parent = %(parent)s ) as idx,
|
|
||||||
bom_item.item_code,
|
bom_item.item_code,
|
||||||
item.item_name,
|
item.item_name,
|
||||||
sum(bom_item.stock_qty/ifnull(bom.quantity, 1)) * %(qty)s as qty,
|
sum(bom_item.stock_qty/ifnull(bom.quantity, 1)) * %(qty)s as qty,
|
||||||
@@ -538,15 +537,15 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite
|
|||||||
if fetch_exploded:
|
if fetch_exploded:
|
||||||
query = query.format(table="BOM Explosion Item",
|
query = query.format(table="BOM Explosion Item",
|
||||||
where_conditions="""and item.is_sub_contracted_item = 0""",
|
where_conditions="""and item.is_sub_contracted_item = 0""",
|
||||||
select_columns = ", bom_item.source_warehouse")
|
select_columns = ", bom_item.source_warehouse, (Select idx from `tabBOM Item` where item_code = bom_item.item_code and parent = %(parent)s ) as idx")
|
||||||
items = frappe.db.sql(query, { "parent": bom, "qty": qty, "bom": bom }, as_dict=True)
|
items = frappe.db.sql(query, { "parent": bom, "qty": qty, "bom": bom }, as_dict=True)
|
||||||
elif fetch_scrap_items:
|
elif fetch_scrap_items:
|
||||||
query = query.format(table="BOM Scrap Item", where_conditions="", select_columns="")
|
query = query.format(table="BOM Scrap Item", where_conditions="", select_columns=", bom_item.idx")
|
||||||
items = frappe.db.sql(query, { "parent": bom, "qty": qty, "bom": bom }, as_dict=True)
|
items = frappe.db.sql(query, { "qty": qty, "bom": bom }, as_dict=True)
|
||||||
else:
|
else:
|
||||||
query = query.format(table="BOM Item", where_conditions="",
|
query = query.format(table="BOM Item", where_conditions="",
|
||||||
select_columns = ", bom_item.source_warehouse")
|
select_columns = ", bom_item.source_warehouse, bom_item.idx")
|
||||||
items = frappe.db.sql(query, { "parent": bom, "qty": qty, "bom": bom }, as_dict=True)
|
items = frappe.db.sql(query, { "qty": qty, "bom": bom }, as_dict=True)
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
if item_dict.has_key(item.item_code):
|
if item_dict.has_key(item.item_code):
|
||||||
|
|||||||
Reference in New Issue
Block a user