Not fetching valuation rate if item is a new part on Sales Order creation

ERPNext v12.4.2
Frappe Framework v12.2.1

Hello Community!

Just a bit of background of our environment. We are a custom equipment manufacturing company. Most of the time we create a new part# for any new custom assemblies that we create.

Now the problem that I encountered. When adding a new Item to a Sales Order if the items hasn’t been received or manufactured the valuation rate is 0 . This leads to 100% gross profit on any new part number that we sell (I know this doesn’t affect the profitability report once invoiced but still this makes it so the sales order report for all open orders show 100% profitability).

On the item page. There is a field “Valuation Rate” in my understanding this field serves as a fallback if no valuation rate has been found. So this field should always be fetched if there is no valuation rate.

I found the code that is called when a new item is added the snippet is below:
erpnext.stock.get_item_details.get_valuation_rate

def get_valuation_rate(item_code, company, warehouse=None):
	item = get_item_defaults(item_code, company)
	item_group = get_item_group_defaults(item_code, company)
	brand = get_brand_defaults(item_code, company)
	# item = frappe.get_doc("Item", item_code)
	if item.get("is_stock_item"):
		if not warehouse:
			warehouse = item.get("default_warehouse") or item_group.get("default_warehouse") or brand.get("default_warehouse")

		return frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
			["valuation_rate"], as_dict=True) or {"valuation_rate": 0}

	elif not item.get("is_stock_item"):
		valuation_rate =frappe.db.sql("""select sum(base_net_amount) / sum(qty*conversion_factor)
			from `tabPurchase Invoice Item`
			where item_code = %s and docstatus=1""", item_code)

		if valuation_rate:
			return {"valuation_rate": valuation_rate[0][0] or 0.0}
	else:
		return {"valuation_rate": 0.0}

My suggestion is if the valuation rate is 0.0 it should then:
valuation_rate = frappe.get_value(‘Item’, filters={‘item_code’: item_code}, ‘valuation_rate’}