From 0ca96bc78901d47983c82754d9634eec0cd98a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Marques?= Date: Wed, 31 Mar 2021 11:28:16 +0100 Subject: [PATCH] [FIX] account_payment_order: Fix tests Don't use taxes in invoices to avoid inconsistency across localization settings Create account instead of relying on environment --- .../tests/test_payment_order_inbound.py | 17 ++++++-------- .../tests/test_payment_order_outbound.py | 22 ++++++------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/account_payment_order/tests/test_payment_order_inbound.py b/account_payment_order/tests/test_payment_order_inbound.py index 886985e0c..914a0b57b 100644 --- a/account_payment_order/tests/test_payment_order_inbound.py +++ b/account_payment_order/tests/test_payment_order_inbound.py @@ -18,16 +18,12 @@ class TestPaymentOrderInboundBase(SavepointCase): self.inbound_mode = self.env.ref( "account_payment_mode.payment_mode_inbound_dd1" ) - self.invoice_line_account = self.env["account.account"].search( - [ - ( - "user_type_id", - "=", - self.env.ref("account.data_account_type_revenue").id, - ), - ("company_id", "=", self.env.user.company_id.id), - ], - limit=1, + self.invoice_line_account = self.env["account.account"].create( + { + "name": "Test account", + "code": "TEST1", + "user_type_id": self.env.ref("account.data_account_type_revenue").id, + } ) self.journal = self.env["account.journal"].search( [("type", "=", "bank"), ("company_id", "=", self.env.user.company_id.id)], @@ -69,6 +65,7 @@ class TestPaymentOrderInboundBase(SavepointCase): invoice_line_form.quantity = 1 invoice_line_form.price_unit = 100.0 invoice_line_form.account_id = self.invoice_line_account + invoice_line_form.tax_ids.clear() invoice = invoice_form.save() invoice_form = Form(invoice) invoice_form.payment_mode_id = self.inbound_mode diff --git a/account_payment_order/tests/test_payment_order_outbound.py b/account_payment_order/tests/test_payment_order_outbound.py index 8dd5d21b0..50de54b2a 100644 --- a/account_payment_order/tests/test_payment_order_outbound.py +++ b/account_payment_order/tests/test_payment_order_outbound.py @@ -15,20 +15,12 @@ class TestPaymentOrderOutbound(TransactionCase): self.journal = self.env["account.journal"].search( [("type", "=", "bank")], limit=1 ) - self.invoice_line_account = ( - self.env["account.account"] - .search( - [ - ( - "user_type_id", - "=", - self.env.ref("account.data_account_type_expenses").id, - ), - ("company_id", "=", self.env.user.company_id.id), - ], - limit=1, - ) - .id + self.invoice_line_account = self.env["account.account"].create( + { + "name": "Test account", + "code": "TEST1", + "user_type_id": self.env.ref("account.data_account_type_expenses").id, + } ) self.invoice = self._create_supplier_invoice() self.invoice_02 = self._create_supplier_invoice() @@ -65,7 +57,7 @@ class TestPaymentOrderOutbound(TransactionCase): "quantity": 1.0, "price_unit": 100.0, "name": "product that cost 100", - "account_id": self.invoice_line_account, + "account_id": self.invoice_line_account.id, }, ) ],