From 689b77d1ed39027c2a13b415a1f86a69cafeee07 Mon Sep 17 00:00:00 2001 From: marination Date: Mon, 26 Oct 2020 16:28:39 +0530 Subject: [PATCH] fix: Don't show buttons if status is Completed --- .../production_plan/production_plan.js | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.js b/erpnext/manufacturing/doctype/production_plan/production_plan.js index b29fd4cf43..b723387a09 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.js +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.js @@ -57,31 +57,31 @@ frappe.ui.form.on('Production Plan', { if (frm.doc.docstatus === 1) { frm.trigger("show_progress"); - if (frm.doc.status === "Closed") { - frm.add_custom_button(__("Re-open"), function() { - frm.events.close_open_production_plan(frm, false); - }, __("Status")); - } else { - frm.add_custom_button(__("Close"), function() { - frm.events.close_open_production_plan(frm, true); - }, __("Status")); + if (frm.doc.status !== "Completed") { + if (frm.doc.po_items && frm.doc.status !== "Closed") { + frm.add_custom_button(__("Work Order"), ()=> { + frm.trigger("make_work_order"); + }, __('Create')); + } + + if (frm.doc.mr_items && !in_list(['Material Requested', 'Closed'], frm.doc.status)) { + frm.add_custom_button(__("Material Request"), ()=> { + frm.trigger("make_material_request"); + }, __('Create')); + } + + if (frm.doc.status === "Closed") { + frm.add_custom_button(__("Re-open"), function() { + frm.events.close_open_production_plan(frm, false); + }, __("Status")); + } else { + frm.add_custom_button(__("Close"), function() { + frm.events.close_open_production_plan(frm, true); + }, __("Status")); + } } } - if (frm.doc.docstatus === 1 && frm.doc.po_items - && !in_list(['Closed', 'Completed'], frm.doc.status)) { - frm.add_custom_button(__("Work Order"), ()=> { - frm.trigger("make_work_order"); - }, __('Create')); - } - - if (frm.doc.docstatus === 1 && frm.doc.mr_items - && !in_list(['Material Requested', 'Completed', 'Closed'], frm.doc.status)) { - frm.add_custom_button(__("Material Request"), ()=> { - frm.trigger("make_material_request"); - }, __('Create')); - } - if (frm.doc.status !== "Closed") { frm.page.set_inner_btn_group_as_primary(__('Create')); }