When using the accounting module in Odoo 10. I've problem with the default e-mail template would like to send the invoice to the e-mail address of the company instead of the invoice contact that I've assigned to the company.
It seems like you can edit a template for the e-mail and the to-field is set to ${object.partner_id.id}
how can I find the corresponding code for the company invoice contact?
I found out that the user object has a type property. When that property is set to 'invoice' that user is the linked company invoice contact. But cannot connect the company on the invoice to it's users and test the type property.
You can try accessing back to the Sales Order from the invoice object.
However, if there's no
sale_id
(typically this would only be for manually created invoices), you'll probably want to identify a fallback for the template to use. In this case, it's going to use the Sales Order's Partner ID, otherwise the Invoice's partner ID.The above could potentially cause an error if there's no
sale_id
, so you may have to do something a little more clunky such as: