From ebd45878c3e74cbebe698762938d3ee21212db7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ei=C3=9Fler?= <77415730+PatrickDEissler@users.noreply.github.com> Date: Wed, 9 Jul 2025 13:52:12 +0200 Subject: [PATCH] feat(BOM): improve tree display with item_name and qty (#48176) 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 3a658c9aa21..cd233cbf234 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -1336,7 +1336,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 cf2e56c6f03..cbf09a618cf 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; }