diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.js b/erpnext/manufacturing/doctype/production_plan/production_plan.js index 53a8b80625..2406235324 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.js +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.js @@ -126,6 +126,20 @@ frappe.ui.form.on('Production Plan', { }, make_material_request: function(frm) { + + frappe.confirm(__("Do you want to submit the material request"), + function() { + frm.events.create_material_request(frm, 1); + }, + function() { + frm.events.create_material_request(frm, 0); + } + ); + }, + + create_material_request: function(frm, submit) { + frm.doc.submit_material_request = submit; + frappe.call({ method: "make_material_request", freeze: true, diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py index ba1c4e7854..06f238aa5c 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py @@ -395,7 +395,11 @@ class ProductionPlan(Document): # submit material_request.flags.ignore_permissions = 1 material_request.run_method("set_missing_values") - material_request.submit() + + if self.get('submit_material_request'): + material_request.submit() + else: + material_request.save() frappe.flags.mute_messages = False diff --git a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py index e9ef70c49b..f70c9cc43f 100644 --- a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py @@ -51,7 +51,8 @@ class TestProductionPlan(unittest.TestCase): for name in material_requests: mr = frappe.get_doc('Material Request', name[0]) - mr.cancel() + if mr.docstatus != 0: + mr.cancel() for name in work_orders: mr = frappe.delete_doc('Work Order', name[0])