Create invoice to a company and send it with email to the companies invoice address in Odoo 10

414 views Asked by At

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.

1

There are 1 answers

3
travisw On

You can try accessing back to the Sales Order from the invoice object.

${object.sale_id.partner_id.id}

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.

${object.sale_id.partner_id.id or object.partner_id.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:

${object.sale_id and object.sale_id.partner_id.id or object.partner_id.id}