move bom based rate calculation to end (#9271)

diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 2cf2f40..bbfdc9a 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -138,8 +138,6 @@
 
 		if arg.get('scrap_items'):
 			rate = self.get_valuation_rate(arg)
-		elif arg['bom_no']:
-			rate = self.get_bom_unitcost(arg['bom_no'])
 		elif arg:
 			if self.rm_cost_as_per == 'Valuation Rate':
 				rate = self.get_valuation_rate(arg)
@@ -151,6 +149,9 @@
 				rate = frappe.db.get_value("Item Price", {"price_list": self.buying_price_list,
 					"item_code": arg["item_code"]}, "price_list_rate") or 0
 
+		if not rate and arg['bom_no']:
+			rate = self.get_bom_unitcost(arg['bom_no'])
+
 		return rate
 
 	def update_cost(self):