fix: Don't show buttons if status is Completed

This commit is contained in:
marination 2020-10-26 16:28:39 +05:30
parent 097b32fe67
commit 689b77d1ed

View File

@ -57,6 +57,19 @@ frappe.ui.form.on('Production Plan', {
if (frm.doc.docstatus === 1) { if (frm.doc.docstatus === 1) {
frm.trigger("show_progress"); frm.trigger("show_progress");
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") { if (frm.doc.status === "Closed") {
frm.add_custom_button(__("Re-open"), function() { frm.add_custom_button(__("Re-open"), function() {
frm.events.close_open_production_plan(frm, false); frm.events.close_open_production_plan(frm, false);
@ -67,19 +80,6 @@ frappe.ui.form.on('Production Plan', {
}, __("Status")); }, __("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") { if (frm.doc.status !== "Closed") {