Skip to content

Commit

Permalink
fix(ux): hide new version btn on unsaved BOM (#31297)
Browse files Browse the repository at this point in the history
(cherry picked from commit d9a5213)
  • Loading branch information
ankush authored and mergify[bot] committed Jun 9, 2022
1 parent 633a452 commit de7b011
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions erpnext/manufacturing/doctype/bom/bom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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() {
Expand Down

0 comments on commit de7b011

Please sign in to comment.