diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.js b/erpnext/manufacturing/doctype/production_plan/production_plan.js index f381c9d39e2..ab09a0f02f9 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.js +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.js @@ -334,7 +334,7 @@ frappe.ui.form.on("Production Plan", { frm.set_value("consider_minimum_order_qty", 0); - if (frm.doc.ignore_existing_ordered_qty) { + if (!frm.doc.ignore_existing_ordered_qty) { frm.events.get_items_for_material_requests(frm); } else { const title = __("Transfer Materials For Warehouse {0}", [frm.doc.for_warehouse]); diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.json b/erpnext/manufacturing/doctype/production_plan/production_plan.json index bd2cccddda2..01ab5fc7301 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.json +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.json @@ -230,11 +230,11 @@ "label": "Include Subcontracted Items" }, { - "default": "0", - "description": "If enabled, the system will create material requests even if the stock exists in the 'Raw Materials Warehouse'.", + "default": "1", + "description": "If enabled, the system will consider items with a shortfall in quantity. \n
\nQty = Reqd Qty (BOM) - Projected Qty", "fieldname": "ignore_existing_ordered_qty", "fieldtype": "Check", - "label": "Ignore Available Stock" + "label": "Skip Available Raw Materials" }, { "fieldname": "column_break_25", @@ -249,7 +249,7 @@ { "fieldname": "get_items_for_mr", "fieldtype": "Button", - "label": "Get Raw Materials for Purchase" + "label": "Get Items for Purchase Only" }, { "fieldname": "section_break_27", @@ -391,9 +391,10 @@ "label": "Consolidate Sub Assembly Items" }, { + "description": "If items in stock, proceed with Material Transfer or Purchase.", "fieldname": "transfer_materials", "fieldtype": "Button", - "label": "Get Raw Materials for Transfer" + "label": "Get Items for Purchase / Transfer" }, { "collapsible": 1, @@ -402,8 +403,8 @@ "label": "Preview Required Materials" }, { - "default": "0", - "description": "If this checkbox is enabled, then the system won\u2019t run the MRP for the available sub-assembly items.", + "default": "1", + "description": "If enabled, the system will consider items with a shortfall in quantity. \n
\nQty = Reqd Qty (BOM) - Projected Qty", "fieldname": "skip_available_sub_assembly_item", "fieldtype": "Check", "label": "Skip Available Sub Assembly Items" @@ -436,11 +437,12 @@ "label": "Consider Minimum Order Qty" } ], + "grid_page_length": 50, "icon": "fa fa-calendar", "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2025-01-10 17:47:52.207209", + "modified": "2025-04-08 17:24:09.394056", "modified_by": "Administrator", "module": "Manufacturing", "name": "Production Plan", @@ -461,7 +463,8 @@ "write": 1 } ], + "row_format": "Dynamic", "sort_field": "creation", "sort_order": "ASC", "states": [] -} \ No newline at end of file +} diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py index 208cec97579..1e35b4e7311 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py @@ -1329,7 +1329,7 @@ def get_material_request_items( total_qty = row["qty"] required_qty = 0 - if ignore_existing_ordered_qty or bin_dict.get("projected_qty", 0) < 0: + if not ignore_existing_ordered_qty or bin_dict.get("projected_qty", 0) < 0: required_qty = total_qty elif total_qty > bin_dict.get("projected_qty", 0): required_qty = total_qty - bin_dict.get("projected_qty", 0) @@ -1688,7 +1688,7 @@ def get_items_for_material_requests(doc, warehouses=None, get_parent_warehouse_d if items: mr_items.append(items) - if (not ignore_existing_ordered_qty or get_parent_warehouse_data) and warehouses: + if (ignore_existing_ordered_qty or get_parent_warehouse_data) and warehouses: new_mr_items = [] for item in mr_items: get_materials_from_other_locations(item, warehouses, new_mr_items, company) diff --git a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py index 7c1dba8be91..ab0abb4d48c 100644 --- a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py @@ -180,7 +180,7 @@ class TestProductionPlan(IntegrationTestCase): ) pln = create_production_plan( - item_code="Test Production Item 1", use_multi_level_bom=0, ignore_existing_ordered_qty=0 + item_code="Test Production Item 1", use_multi_level_bom=0, ignore_existing_ordered_qty=1 ) self.assertFalse(len(pln.mr_items)) @@ -725,6 +725,7 @@ class TestProductionPlan(IntegrationTestCase): }, ) + pln.skip_available_sub_assembly_item = 0 pln.get_sub_assembly_items("In House") pln.submit() pln.make_work_order() @@ -1454,6 +1455,7 @@ class TestProductionPlan(IntegrationTestCase): ) plan.for_warehouse = mrp_warhouse + plan.ignore_existing_ordered_qty = 1 items = get_items_for_material_requests( plan.as_dict(), warehouses=[{"warehouse": wh1}, {"warehouse": wh2}] @@ -1690,6 +1692,7 @@ class TestProductionPlan(IntegrationTestCase): ) pln.for_warehouse = rm_warehouse + pln.ignore_existing_ordered_qty = 1 items = get_items_for_material_requests(pln.as_dict(), warehouses=[{"warehouse": store_warehouse}]) for row in items: @@ -1891,6 +1894,7 @@ class TestProductionPlan(IntegrationTestCase): }, ) plan.save() + plan.ignore_existing_ordered_qty = 1 plan.get_sub_assembly_items()