Append to Tree View

I am trying to append information to the item names in a Tree view without success. For example, n the Chart of Accounts Tree View, there is the account name appended to the company abbreviation with an ‘-’ as shown:

image

I have combed through both the tree.js file and the utils.py file trying to figure out where those fields are appended without success. Could someone point me in the right location where this happens? My end goal is to modify the BOM tree view to include the item name and cost in the same manner.

1 Like

I figured it out somewhat. If someone needs a more functional v10 BOM tree view, try replacing the get_label function in the bom_tree.js file with the code below. It will add the item name, quantity, unit of measure and item cost to the BOM Tree.

get_label: function(node) {
	 if(!node.data.item_code) {
		return node.data.item_code || node.data.value;
	}
	else if(node.data.value) {
		return node.data.value + "  " + node.data.title + " $" + node.data.amount.toFixed(2);
	}
	else {
		return node.data.item_code + "  " + node.data.title + ", QTY: " + node.data.stock_qty + " " + node.data.stock_uom + ", $" + node.data.amount.toFixed(2);
	}
},

You also have to change the query in the bom.py file with this:

def get_children(doctype, parent=None, is_root=False, **filters):

if frappe.form_dict.parent:
	return frappe.db.sql("""select
		bom_item.item_code,
		bom_item.bom_no as value,
		bom_item.stock_qty,
		bom_item.item_name as title,
		bom_item.amount,
		bom_item.stock_uom,
		if(ifnull(bom_item.bom_no, "")!="", 1, 0) as expandable,
		item.image,
		item.description
		from `tabBOM Item` bom_item, tabItem item
		where bom_item.parent=%s
		and bom_item.item_code = item.name
		order by bom_item.idx
		""", frappe.form_dict.parent, as_dict=True) """
2 Likes

hi everyone i am trying to customize the item group tree to show items that are related to the particular group as a list within their parent group.
For e.g:
Categories
-Products
–Electronics
—Computers
----HP
-----item 1
-----item 2
-----item 3
-----item 4
-----item 5
----Lenovo
----Dell

Any ideas of how i would go about this to accomplish this task.

have you achieved it?