Fix retrieving of margin info when invoice created automatically from order.

(used by workflow module)