diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index a29f7ba40cc..0a436ba3a52 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -662,7 +662,7 @@ class PosOrder(models.Model): 'journal_id': self.session_id.config_id.invoice_journal_id.id, 'move_type': 'out_invoice' if self.amount_total >= 0 else 'out_refund', 'ref': self.name, - 'partner_id': self.partner_id.id, + 'partner_id': self.partner_id.address_get(['invoice'])['invoice'], 'partner_bank_id': self._get_partner_bank_id(), 'currency_id': self.currency_id.id, 'invoice_user_id': self.user_id.id, diff --git a/addons/point_of_sale/tests/test_point_of_sale_flow.py b/addons/point_of_sale/tests/test_point_of_sale_flow.py index c466ce1a8ca..307db8b8dd4 100644 --- a/addons/point_of_sale/tests/test_point_of_sale_flow.py +++ b/addons/point_of_sale/tests/test_point_of_sale_flow.py @@ -543,6 +543,13 @@ class TestPointOfSaleFlow(TestPointOfSaleCommon): def test_order_to_invoice(self): + invoice_partner_address = self.env["res.partner"].create({ + 'name': "Test invoice address", + 'street': "Invoice Street", + 'type': 'invoice', + 'parent_id': self.partner1.id, + }) + self.pos_config.open_ui() current_session = self.pos_config.current_session_id @@ -597,6 +604,7 @@ class TestPointOfSaleFlow(TestPointOfSaleCommon): # I generate an invoice from the order res = self.pos_order_pos1.action_pos_order_invoice() self.assertIn('res_id', res, "Invoice should be created") + self.assertEqual(self.pos_order_pos1.account_move.partner_id.id, invoice_partner_address.id, "Invoice address should be used") # I test that the total of the attached invoice is correct invoice = self.env['account.move'].browse(res['res_id'])