It’s an old thread, but people might still find it searching for a solution.
You can find a solution here (from June 2025):
if use standard data import, simply fill the the number into ID field, the ID field has highest priority which will prevent autoname by naming series.
if create sales order via api, you can create before_insert server script with code like below
doc.name = f"{number}"
doc.flags.name_set = True
In other words: Using the Script API, create your document with the usual construct, including the legacy number as name (e.g. “ID”), and then use this specific flag to signal that you want to use the already set name as is.
my_new_doc = frappe.get_doc({
"doctype": "ToDo",
"description": "Setting my own name",
"name": "11321-3XL-RS"
})
my_new_doc.flags.name_set = True
my_new_doc.insert()
To confirm it works, simply check the ToDo list to verify that the name indeed got through as expected.