From fdd79c767780db2407a566b6bbb10e294b87bf3f Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 9 Jul 2025 14:13:24 +0200 Subject: [PATCH] feat(BOM): improve tree display with item_name and qty (backport #48176) (#48494) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Patrick Eißler <77415730+PatrickDEissler@users.noreply.github.com> Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com> --- erpnext/manufacturing/doctype/bom/bom.py | 2 +- erpnext/manufacturing/doctype/bom/bom_tree.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index bf6bf2530ce..047b39df54f 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -1274,7 +1274,7 @@ def get_children(parent=None, is_root=False, **filters): bom_items = frappe.get_all( "BOM Item", - fields=["item_code", "bom_no as value", "stock_qty"], + fields=["item_code", "bom_no as value", "stock_qty", "qty"], filters=[["parent", "=", frappe.form_dict.parent]], order_by="idx", ) diff --git a/erpnext/manufacturing/doctype/bom/bom_tree.js b/erpnext/manufacturing/doctype/bom/bom_tree.js index 534de0e654b..9b4b3c8f96c 100644 --- a/erpnext/manufacturing/doctype/bom/bom_tree.js +++ b/erpnext/manufacturing/doctype/bom/bom_tree.js @@ -16,7 +16,14 @@ frappe.treeview_settings["BOM"] = { show_expand_all: false, get_label: function (node) { if (node.data.qty) { - return node.data.qty + " x " + node.data.item_code; + 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; }