diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index a06645ad9f..fb52d5260c 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -592,7 +592,7 @@ def validate_bom_no(item, bom_no): @frappe.whitelist() def get_children(doctype, parent=None, is_root=False, **filters): - if not parent: + if not parent or parent=="BOM": frappe.msgprint(_('Please select a BOM')) return diff --git a/erpnext/manufacturing/doctype/bom/bom_tree.js b/erpnext/manufacturing/doctype/bom/bom_tree.js index 854f6334d7..6cbd7a2ab1 100644 --- a/erpnext/manufacturing/doctype/bom/bom_tree.js +++ b/erpnext/manufacturing/doctype/bom/bom_tree.js @@ -11,7 +11,8 @@ frappe.treeview_settings["BOM"] = { title: "BOM", breadcrumb: "Manufacturing", disable_add_node: true, - root_label: "All Bill of Materials", //fieldname from filters + root_label: "BOM", //fieldname from filters + get_tree_root: false, get_label: function(node) { if(node.data.qty) { return node.data.qty + " x " + node.data.item_code; @@ -19,6 +20,23 @@ frappe.treeview_settings["BOM"] = { return node.data.item_code || node.data.value; } }, + onload: function(me) { + var label = frappe.get_route()[0] + "/" + frappe.get_route()[1]; + if(frappe.pages[label]) { + delete frappe.pages[label]; + } + + var filter = me.opts.filters[0]; + if(frappe.route_options && frappe.route_options[filter.fieldname]) { + var val = frappe.route_options[filter.fieldname]; + delete frappe.route_options[filter.fieldname]; + filter.default = ""; + me.args[filter.fieldname] = val; + me.root_label = val; + me.page.set_title(val); + } + me.make_tree(); + }, toolbar: [ { toggle_btn: true }, {