Skip to content

Commit

Permalink
fix: Returned Qty in Work Order Consumed Materials report
Browse files Browse the repository at this point in the history
(cherry picked from commit 30d68a3)
  • Loading branch information
rohitwaghchaure authored and mergify[bot] committed Jan 6, 2025
1 parent 01254da commit f7b501b
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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():
Expand Down

0 comments on commit f7b501b

Please sign in to comment.