[FIX] sale: down payment invoice has correct company

How to reproduce:

- Have a databas with 2 companies (A and B)
- Create and confirm a sale with company A
- Switch to company B
- Create a down payment invoice.

Bug:

When generating an invoice from a sale, the company of the invoice
should always be the one from the sale.

closes odoo/odoo#80523

Opw: 2631354
X-original-commit: a345d2f4a45179b1c3cecb5be983d3ef2435d0f8
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
Adrien Minet
2021-11-29 13:09:55 +00:00
parent 5d184c5fd8
commit 2a090cbb9b
@@ -125,7 +125,9 @@ class SaleAdvancePaymentInv(models.TransientModel):
if order.fiscal_position_id:
invoice_vals['fiscal_position_id'] = order.fiscal_position_id.id
invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid)
invoice = self.env['account.move'].with_company(order.company_id)\
.sudo().create(invoice_vals).with_user(self.env.uid)
invoice.message_post_with_view('mail.message_origin_link',
values={'self': invoice, 'origin': order},
subtype_id=self.env.ref('mail.mt_note').id)