Use reference as origin name
The origin name is used on invoices and shipments in the report as reference.
Indeed if there is a reference on the sale, it is often because the customer requested to have it on all documents (ex: invoice and delivery note). So I think in such case the origin name should be the reference if filled.
The same apply on the purchase if the user entered a supplier reference, this reference will probably be also on the invoice.