[fix] get bom items query
This commit is contained in:
parent
d57e793bf3
commit
2878cc7757
@ -395,30 +395,23 @@ def get_bom_items_as_dict(bom, qty=1, fetch_exploded=1):
|
|||||||
item.expense_account as expense_account,
|
item.expense_account as expense_account,
|
||||||
item.buying_cost_center as cost_center
|
item.buying_cost_center as cost_center
|
||||||
from
|
from
|
||||||
`tab%(table)s` bom_item, `tabBOM` bom, `tabItem` item
|
`tab{table}` bom_item, `tabBOM` bom, `tabItem` item
|
||||||
where
|
where
|
||||||
bom_item.parent = bom.name
|
bom_item.parent = bom.name
|
||||||
and bom_item.docstatus < 2
|
and bom_item.docstatus < 2
|
||||||
and bom_item.parent = "%(bom)s"
|
and bom_item.parent = %(bom)s
|
||||||
and item.name = bom_item.item_code
|
and item.name = bom_item.item_code
|
||||||
%(conditions)s
|
{conditions}
|
||||||
group by item_code, stock_uom"""
|
group by item_code, stock_uom"""
|
||||||
|
|
||||||
if fetch_exploded:
|
if fetch_exploded:
|
||||||
items = frappe.db.sql(query % {
|
query = query.format(table="BOM Explosion Item",
|
||||||
"qty": qty,
|
conditions="""and ifnull(item.is_pro_applicable, 'No') = 'No'
|
||||||
"table": "BOM Explosion Item",
|
and ifnull(item.is_sub_contracted_item, 'No') = 'No' """)
|
||||||
"bom": bom,
|
items = frappe.db.sql(query, { "qty": qty, "bom": bom }, as_dict=True)
|
||||||
"conditions": """and ifnull(item.is_pro_applicable, 'No') = 'No'
|
|
||||||
and ifnull(item.is_sub_contracted_item, 'No') = 'No' """
|
|
||||||
}, as_dict=True)
|
|
||||||
else:
|
else:
|
||||||
items = frappe.db.sql(query % {
|
query = query.format(table="BOM Item", conditions="")
|
||||||
"qty": qty,
|
items = frappe.db.sql(query, { "qty": qty, "bom": bom }, as_dict=True)
|
||||||
"table": "BOM Item",
|
|
||||||
"bom": bom,
|
|
||||||
"conditions": ""
|
|
||||||
}, as_dict=True)
|
|
||||||
|
|
||||||
# make unique
|
# make unique
|
||||||
for item in items:
|
for item in items:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user