Merge pull request #45109 from frappe/mergify/bp/version-15-hotfix/pr-45107

fix: Returned Qty in Work Order Consumed Materials report (backport #45107)
This commit is contained in:
ruthra kumar
2025-01-07 10:12:43 +05:30
committed by GitHub

View File

@@ -50,7 +50,11 @@ def get_returned_materials(work_orders):
raw_materials = frappe.get_all(
"Stock Entry",
fields=["`tabStock Entry Detail`.`item_code`", "`tabStock Entry Detail`.`qty`"],
fields=[
"`tabStock Entry`.`work_order`",
"`tabStock Entry Detail`.`item_code`",
"`tabStock Entry Detail`.`qty`",
],
filters=[
["Stock Entry", "is_return", "=", 1],
["Stock Entry Detail", "docstatus", "=", 1],
@@ -59,12 +63,14 @@ def get_returned_materials(work_orders):
)
for d in raw_materials:
raw_materials_qty[d.item_code] += d.qty
key = (d.work_order, d.item_code)
raw_materials_qty[key] += d.qty
for row in work_orders:
row.returned_qty = 0.0
if raw_materials_qty.get(row.raw_material_item_code):
row.returned_qty = raw_materials_qty.get(row.raw_material_item_code)
key = (row.parent, row.raw_material_item_code)
if raw_materials_qty.get(key):
row.returned_qty = raw_materials_qty.get(key)
def get_fields():