From 32447b8204c40486f6bd59f95dba9b9eb2cf58ac Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 9 Mar 2026 16:23:31 +0530 Subject: [PATCH] fix: bom UX issues --- erpnext/manufacturing/doctype/bom/bom.js | 11 ++++- erpnext/manufacturing/doctype/bom/bom_tree.js | 41 ++++++++++++++----- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index 44cddac46d6..9ae05611b6c 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -637,11 +637,18 @@ erpnext.bom.BomController = class BomController extends erpnext.TransactionContr } buying_price_list(doc) { - this.apply_price_list(); + if (doc.rm_cost_as_per !== "Price List" && doc.buying_price_list) { + this.frm.set_value("buying_price_list", ""); + return; + } + + if (doc.buying_price_list) { + this.apply_price_list(); + } } plc_conversion_rate(doc) { - if (!this.in_apply_price_list) { + if (!this.in_apply_price_list && doc.rm_cost_as_per === "Price List") { this.apply_price_list(null, true); } } diff --git a/erpnext/manufacturing/doctype/bom/bom_tree.js b/erpnext/manufacturing/doctype/bom/bom_tree.js index cbf09a618cf..c4ecb853d7b 100644 --- a/erpnext/manufacturing/doctype/bom/bom_tree.js +++ b/erpnext/manufacturing/doctype/bom/bom_tree.js @@ -15,18 +15,18 @@ frappe.treeview_settings["BOM"] = { get_tree_root: false, show_expand_all: false, get_label: function (node) { - if (node.data.qty) { - const escape = frappe.utils.escape_html; - let label = escape(node.data.item_code); - if (node.data.item_name && node.data.item_code !== node.data.item_name) { - label += `: ${escape(node.data.item_name)}`; - } - return `${label} ${node.data.qty} ${escape( - __(node.data.stock_uom) - )}`; - } else { - return node.data.item_code || node.data.value; + if (node.is_root && node.data.value != "BOM") { + frappe.model.with_doc("BOM", node.data.value, function () { + var bom = frappe.model.get_doc("BOM", node.data.value); + node.data.item_name = bom.item_name || ""; + node.data.item_code = bom.item || ""; + node.data.qty = bom.quantity || ""; + node.data.stock_uom = bom.uom || ""; + return get_bom_node(node); + }); } + + return get_bom_node(node); }, onload: function (me) { var label = frappe.get_route()[0] + "/" + frappe.get_route()[1]; @@ -78,3 +78,22 @@ frappe.treeview_settings["BOM"] = { }, view_template: "bom_item_preview", }; + +function get_bom_node(node) { + if (node.data.qty) { + const escape = frappe.utils.escape_html; + let label = escape(node.data.item_code); + if (node.is_root && node.data.value != "BOM") { + label = escape(node.data.value); + } + + if (node.data.item_name && node.data.item_code !== node.data.item_name) { + label += `: ${escape(node.data.item_name)}`; + } + return `${label} ${node.data.qty} ${escape( + __(node.data.stock_uom) + )}`; + } else { + return node.data.item_code || node.data.value; + } +}