Material request type always set to Purchase when created from SO -> Request for Raw Materials

I am trying to implement self-hosted ERPNext for a job order processing company. Their process is to get the raw material from customer, process it and deliver it back to the customer. I have already created 3 items

  1. Raw material Item - This has “Is Customer Provided” set and “Allow Purchase” unselected
  2. Finished Good Item
  3. Service Item

When I make a “Request for Raw Material” from the Sale order, its picking up the correct item through BOM but its creating the Material Request with type “Purchase” instead of “Customer Provided”.

Any way to fix this so that the Material Request takes the correct type based on the item?

Just checked the code which is used for creating the material request and noticed, the type is hardcoded as “Purchase”. Can it be modified so that it used “Customer Provided” if the field is_customer_provided_item is set against the item.

erpnext/erpnext/selling/doctype/sales_order/sales_order.py

	material_request = frappe.new_doc("Material Request")
	material_request.update(
		dict(
			doctype="Material Request",
			transaction_date=nowdate(),
			company=company,
			material_request_type="Purchase",
		)
	)

Production Plan creates the Material Request with correct type. Will explore using this option.

Adding a default material request type field in the stock/manufacturing settings based on which this field is populated would be the ideal scenario. ERPNext team has to update this though. Raise an Issue in GitHub?

Same thing with default stock entry type for stock entry created from the material request. It’s also hardcoded I believe and should be selectable in settings.