fix: broken bom tree view and remove duplicate button (#28512) (#28527)

* fix: broken bom tree view and remove duplicate button

(cherry picked from commit 7ae1369d64ecaa829965d89915475fbd3211b5c2)

Co-authored-by: Bhavesh Maheshwari <34086262+bhavesh95863@users.noreply.github.com>
Co-authored-by: Ankush Menat <ankush@frappe.io>
diff --git a/erpnext/manufacturing/doctype/bom/bom_item_preview.html b/erpnext/manufacturing/doctype/bom/bom_item_preview.html
index e614a7e..eb4135e 100644
--- a/erpnext/manufacturing/doctype/bom/bom_item_preview.html
+++ b/erpnext/manufacturing/doctype/bom/bom_item_preview.html
@@ -16,26 +16,15 @@
 			</div>
 			<hr style="margin: 15px -15px;">
 			<p>
-				{% if data.value %}
-				<a style="margin-right: 7px; margin-bottom: 7px" class="btn btn-default btn-xs" href="#Form/BOM/{{ data.value }}">
+				{% if data.value && data.value != "BOM" %}
+				<a style="margin-right: 7px; margin-bottom: 7px" class="btn btn-default btn-xs" href="/app/bom/{{ data.value }}">
 					{{ __("Open BOM {0}", [data.value.bold()]) }}</a>
 				{% endif %}
 				{% if data.item_code %}
-				<a class="btn btn-default btn-xs" href="#Form/Item/{{ data.item_code }}">
+				<a style="margin-right: 7px; margin-bottom: 7px"  class="btn btn-default btn-xs" href="/app/item/{{ data.item_code }}">
 					{{ __("Open Item {0}", [data.item_code.bold()]) }}</a>
 				{% endif %}
 			</p>
 		</div>
 	</div>
-	<hr style="margin: 15px -15px;">
-	<p>
-		{% if data.value %}
-		<a style="margin-right: 7px; margin-bottom: 7px" class="btn btn-default btn-xs" href="/app/Form/BOM/{{ data.value }}">
-			{{ __("Open BOM {0}", [data.value.bold()]) }}</a>
-		{% endif %}
-		{% if data.item_code %}
-		<a class="btn btn-default btn-xs" href="/app/Form/Item/{{ data.item_code }}">
-			{{ __("Open Item {0}", [data.item_code.bold()]) }}</a>
-		{% endif %}
-	</p>
 </div>
diff --git a/erpnext/manufacturing/doctype/bom/bom_tree.js b/erpnext/manufacturing/doctype/bom/bom_tree.js
index 6e2599e..fb99add 100644
--- a/erpnext/manufacturing/doctype/bom/bom_tree.js
+++ b/erpnext/manufacturing/doctype/bom/bom_tree.js
@@ -66,6 +66,7 @@
 				var bom = frappe.model.get_doc("BOM", node.data.value);
 				node.data.image = escape(bom.image) || "";
 				node.data.description = bom.description || "";
+				node.data.item_code = bom.item || "";
 			});
 		}
 	},