From dbe9a4138922b2ae144345fd3619f4e67f9b96dd Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Fri, 28 Jun 2019 12:48:28 +0530 Subject: [PATCH] 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 --- .../doctype/production_plan/production_plan.js | 14 ++++++++++++++ .../doctype/production_plan/production_plan.py | 6 +++++- .../production_plan/test_production_plan.py | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) 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])