From 2a090cbb9b781eb6fa532871d429818e69cbb376 Mon Sep 17 00:00:00 2001 From: Adrien Minet Date: Fri, 26 Nov 2021 15:37:31 +0000 Subject: [PATCH] [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) --- addons/sale/wizard/sale_make_invoice_advance.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index fd91de7e144..cb70230be49 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.py +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -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)