diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py index 90e791fc9ba..5a67725966d 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py @@ -889,7 +889,8 @@ class ProductionPlan(Document): material_request_map = {} for item in self.mr_items: - if not item.quantity: + qty_to_request = flt(item.quantity, item.precision("quantity")) + if qty_to_request <= 0: continue item_doc = frappe.get_cached_doc("Item", item.item_code) @@ -925,7 +926,7 @@ class ProductionPlan(Document): "from_warehouse": item.from_warehouse if material_request_type == "Material Transfer" else None, - "qty": item.quantity, + "qty": qty_to_request, "schedule_date": schedule_date, "warehouse": item.warehouse, "sales_order": item.sales_order, diff --git a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py index c9c266df0bb..3cd459cb574 100644 --- a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py @@ -120,6 +120,23 @@ class TestProductionPlan(FrappeTestCase): self.assertEqual(len(quantities), len(pln.mr_items) - 1) self.assertNotIn(0, quantities) + def test_production_plan_material_request_skips_zero_qty_items(self): + pln = create_production_plan(item_code="Test Production Item 1") + zero_qty_item, requested_item = pln.mr_items + zero_qty_item.quantity = "0" + + pln.make_material_request() + + material_request_items = frappe.get_all( + "Material Request Item", + filters={"production_plan": pln.name}, + fields=["item_code", "qty"], + ) + self.assertEqual( + material_request_items, + [{"item_code": requested_item.item_code, "qty": requested_item.quantity}], + ) + def test_production_plan_start_date(self): "Test if Work Order has same Planned Start Date as Prod Plan." planned_date = add_to_date(date=None, days=3)