From de7b0116783c37c72ae7d528c861b433c0932012 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Thu, 9 Jun 2022 15:33:18 +0530 Subject: [PATCH] fix(ux): hide new version btn on unsaved BOM (#31297) (cherry picked from commit d9a52139523cf095d3cc60cf61483a8d56468595) --- erpnext/manufacturing/doctype/bom/bom.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index ef7a09c3aa74..ae0b26222ee9 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -81,7 +81,7 @@ frappe.ui.form.on("BOM", { } ) - if (!frm.doc.__islocal && frm.doc.docstatus<2) { + if (!frm.is_new() && frm.doc.docstatus<2) { frm.add_custom_button(__("Update Cost"), function() { frm.events.update_cost(frm, true); }); @@ -93,10 +93,12 @@ frappe.ui.form.on("BOM", { }); } - frm.add_custom_button(__("New Version"), function() { - let new_bom = frappe.model.copy_doc(frm.doc); - frappe.set_route("Form", "BOM", new_bom.name); - }); + if (!frm.is_new() && !frm.doc.docstatus == 0) { + frm.add_custom_button(__("New Version"), function() { + let new_bom = frappe.model.copy_doc(frm.doc); + frappe.set_route("Form", "BOM", new_bom.name); + }); + } if(frm.doc.docstatus==1) { frm.add_custom_button(__("Work Order"), function() {