feat(BOM): improve tree display with item_name and qty (backport #48176) (#48494)

Co-authored-by: Patrick Eißler <77415730+PatrickDEissler@users.noreply.github.com>
Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com>
This commit is contained in:
mergify[bot]
2025-07-09 14:13:24 +02:00
committed by GitHub
parent 142de2e2a7
commit fdd79c7677
2 changed files with 9 additions and 2 deletions

View File

@@ -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",
)

View File

@@ -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} <span class="badge badge-pill badge-light">${node.data.qty} ${escape(
__(node.data.stock_uom)
)}</span>`;
} else {
return node.data.item_code || node.data.value;
}