Patch Fixed
diff --git a/erpnext/patches/v4_2/recalculate_bom_cost.py b/erpnext/patches/v4_2/recalculate_bom_cost.py
index 418f423..3a194ff 100644
--- a/erpnext/patches/v4_2/recalculate_bom_cost.py
+++ b/erpnext/patches/v4_2/recalculate_bom_cost.py
@@ -5,12 +5,12 @@
 import frappe
 
 def execute():
-	try:
-		for d in frappe.db.sql("select name from `tabBOM` where docstatus < 2"):
+	for d in frappe.db.sql("select name from `tabBOM` where docstatus < 2"):
+		try:	
 			document = frappe.get_doc('BOM', d[0])
 			if document.docstatus == 1:
 				document.ignore_validate_update_after_submit = True
 				document.calculate_cost()
 			document.save()
-	except:
-		pass
\ No newline at end of file
+		except:
+			pass
\ No newline at end of file