From f13db03c9b801508ab0344fc722b05186805abae Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Fri, 19 Dec 2025 10:33:44 +0530 Subject: [PATCH] test: make corrections to tests based on v15 functionality --- .../production_plan/test_production_plan.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py index 5505be3cafa..85e175af2da 100644 --- a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py @@ -165,6 +165,7 @@ class TestProductionPlan(FrappeTestCase): # Sales orders so1 = make_sales_order(item_code=fg_item_a, qty=1) so2 = make_sales_order(item_code=fg_item_a, qty=1) + so3 = make_sales_order(item_code=fg_item_a, qty=1) # Production plan pln = frappe.get_doc( @@ -194,6 +195,15 @@ class TestProductionPlan(FrappeTestCase): "grand_total": so2.grand_total, }, ) + pln.append( + "sales_orders", + { + "sales_order": so3.name, + "sales_order_date": so3.transaction_date, + "customer": so3.customer, + "grand_total": so3.grand_total, + }, + ) pln.get_items() pln.insert() @@ -202,12 +212,13 @@ class TestProductionPlan(FrappeTestCase): quantities = [d["quantity"] for d in mr_items] rm_qty = sum(quantities) - self.assertEqual(len(mr_items), 2) # one for each SO - self.assertEqual(rm_qty, 1, "Cascading failed: total MR qty should be 1 (2 needed - 1 in stock)") + # Only 2 MR item created - the first SO's requirement is fully covered by stock (v15 behaviour) + self.assertEqual(len(mr_items), 2) + self.assertEqual(rm_qty, 2, "Cascading failed: total MR qty should be 2 (3 needed - 1 in stock)") self.assertEqual( quantities, - [0, 1], - "Cascading failed: first item should consume stock (qty=0), second should need procurement (qty=1)", + [1, 1], + "Cascading failed: only second and third SO should need procurement (qty=1) since first SO consumed stock", ) sr.cancel()