fix: Custom button conditionally visible in draft condition as well
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 96e74cc..5c8efcb 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -238,6 +238,8 @@
 			}, __("Get items from"));
 		}
 
+		frm.events.show_bom_custom_button(frm);
+
 		if (frm.doc.company) {
 			frm.trigger("toggle_display_account_head");
 		}
@@ -253,13 +255,7 @@
 
 	stock_entry_type: function(frm){
 		frm.remove_custom_button('Bill of Materials', "Get items from");
-
-		if (frm.doc.docstatus === 0 &&
-			['Material Issue', 'Material Receipt', 'Material Transfer', 'Send to Subcontractor'].includes(frm.doc.purpose)) {
-				frm.add_custom_button(__('Bill of Materials'), function() {
-					frm.events.get_items_from_bom(frm);
-				}, __("Get items from"));
-		}
+		frm.events.show_bom_custom_button(frm);
 	},
 
 	purpose: function(frm) {
@@ -398,6 +394,15 @@
 		}
 	},
 
+	show_bom_custom_button: function(frm){
+		if (frm.doc.docstatus === 0 &&
+			['Material Issue', 'Material Receipt', 'Material Transfer', 'Send to Subcontractor'].includes(frm.doc.purpose)) {
+				frm.add_custom_button(__('Bill of Materials'), function() {
+					frm.events.get_items_from_bom(frm);
+				}, __("Get items from"));
+		}
+	},
+
 	get_items_from_bom: function(frm) {
 		let filters = function(){
 			return {filters: { docstatus:1 }};
@@ -417,11 +422,11 @@
 			{"fieldname":"fetch", "label":__("Get Items from BOM"), "fieldtype":"Button"}
 		]
 
-		//Exclude field 'Target Warehouse' in case of Material Issue
+		// Exclude field 'Target Warehouse' in case of Material Issue
 		if (frm.doc.purpose == 'Material Issue'){
 			fields.splice(2,1);
 		}
-		//Exclude field 'Source Warehouse' in case of Material Receipt
+		// Exclude field 'Source Warehouse' in case of Material Receipt
 		else if(frm.doc.purpose == 'Material Receipt'){
 			fields.splice(1,1);
 		}