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,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'));
}