feat: Confirmation to submit material request against Production Plan (#18062)
* feat: Confirmation to submit material request against Production Plan
* fix: Test cases for production plan
* fix: Test Cases for production plan
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.js b/erpnext/manufacturing/doctype/production_plan/production_plan.js
index 53a8b80..2406235 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.js
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.js
@@ -126,6 +126,20 @@
},
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 ba1c4e7..06f238a 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py
@@ -395,7 +395,11 @@
# 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 e9ef70c..f70c9cc 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 @@
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])