How to programmatically name a document before it is autonamed

I am working on a custom integration that imports sales orders that already have a number. But I can’t figure out how to name it before it is automatically named.

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
1 Like

Thank you. That

doc.flags.name_set = True

was all I neded