Origin name from Reference field must test if id is greater than 0
The reference field when filled with just the model but no record id, is still an instance of a Model. So before accessing any of its properties, we must check if the record is a saved record.
Ref: https://discuss.tryton.org/t/error-when-i-want-to-get-customer-invoice-post/7815