fix: skip zero quantity items in production plan material requests (#58642)

This commit is contained in:
Krishna Pramod Shirsath
2026-09-02 13:32:41 +05:30
committed by GitHub
parent 865b207340
commit 3217a69fc2
2 changed files with 16 additions and 0 deletions

View File

@@ -887,6 +887,9 @@ class ProductionPlan(Document):
material_request_map = {}
for item in self.mr_items:
if not item.quantity:
continue
item_doc = frappe.get_cached_doc("Item", item.item_code)
material_request_type = item.material_request_type or item_doc.default_material_request_type

View File

@@ -107,6 +107,19 @@ class TestProductionPlan(FrappeTestCase):
pln = frappe.get_doc("Production Plan", pln.name)
pln.cancel()
def test_production_plan_mr_creation_skips_zero_qty(self):
pln = create_production_plan(item_code="Test Production Item 1", do_not_submit=1)
pln.mr_items[0].quantity = 0
pln.save().submit()
pln.make_material_request()
quantities = frappe.get_all(
"Material Request Item", filters={"production_plan": pln.name}, pluck="qty"
)
self.assertEqual(len(quantities), len(pln.mr_items) - 1)
self.assertNotIn(0, quantities)
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)