From e6093981f4205c5ff98f2ea4838c9d6a2d66d419 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Mon, 23 Dec 2024 21:59:18 +0100 Subject: [PATCH] [IMP] account_payment_order: Remove dependancies on demo data on tests --- account_payment_order/tests/test_bank.py | 17 ++++++++++++++++- .../tests/test_payment_order_inbound.py | 8 +++++++- .../tests/test_payment_order_outbound.py | 10 ++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/account_payment_order/tests/test_bank.py b/account_payment_order/tests/test_bank.py index 218f96b78..5ec150554 100644 --- a/account_payment_order/tests/test_bank.py +++ b/account_payment_order/tests/test_bank.py @@ -15,6 +15,21 @@ class TestBank(TransactionCase): def test_bank(self): bank = self.env["res.bank"].search([], limit=1) - self.assertTrue(bank) + if not bank: + # This should only happen if we don't have demo data + bank = ( + self.env["res.bank"] + .env["res.bank"] + .create( + { + "name": "Fiducial Banque", + "bic": "FIDCFR21XXX", + "street": "38 rue Sergent Michel Berthet", + "zip": "69009", + "city": "Lyon", + "country": self.env.ref("base.fr").id, + } + ) + ) with self.assertRaises(ValidationError): bank.bic = "TEST" diff --git a/account_payment_order/tests/test_payment_order_inbound.py b/account_payment_order/tests/test_payment_order_inbound.py index f71a2ea60..18bd8c2a0 100644 --- a/account_payment_order/tests/test_payment_order_inbound.py +++ b/account_payment_order/tests/test_payment_order_inbound.py @@ -23,6 +23,12 @@ class TestPaymentOrderInboundBase(AccountTestInvoicingCommon): cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) cls.company = cls.company_data["company"] cls.env.user.company_id = cls.company.id + cls.product = cls.env["product.product"].create( + { + "name": "Test product", + "type": "service", + } + ) cls.partner = cls.env["res.partner"].create( { "name": "Test Partner", @@ -71,7 +77,7 @@ class TestPaymentOrderInboundBase(AccountTestInvoicingCommon): ) as invoice_form: invoice_form.partner_id = self.partner with invoice_form.invoice_line_ids.new() as invoice_line_form: - invoice_line_form.product_id = self.env.ref("product.product_product_4") + invoice_line_form.product_id = self.product invoice_line_form.name = "product that cost 100" invoice_line_form.quantity = 1 invoice_line_form.price_unit = 100.0 diff --git a/account_payment_order/tests/test_payment_order_outbound.py b/account_payment_order/tests/test_payment_order_outbound.py index 0e5bfffc9..54555e020 100644 --- a/account_payment_order/tests/test_payment_order_outbound.py +++ b/account_payment_order/tests/test_payment_order_outbound.py @@ -53,6 +53,12 @@ class TestPaymentOrderOutboundBase(AccountTestInvoicingCommon): ).id, } ) + cls.product = cls.env["product.product"].create( + { + "name": "Test product", + "type": "service", + } + ) cls.invoice = cls._create_supplier_invoice(cls, "F1242") cls.invoice_02 = cls._create_supplier_invoice(cls, "F1243") cls.bank_journal = cls.company_data["default_journal_bank"] @@ -77,7 +83,7 @@ class TestPaymentOrderOutboundBase(AccountTestInvoicingCommon): 0, None, { - "product_id": self.env.ref("product.product_product_4").id, + "product_id": self.product.id, "quantity": 1.0, "price_unit": 100.0, "name": "product that cost 100", @@ -104,7 +110,7 @@ class TestPaymentOrderOutboundBase(AccountTestInvoicingCommon): 0, None, { - "product_id": self.env.ref("product.product_product_4").id, + "product_id": self.product.id, "quantity": 1.0, "price_unit": 90.0, "name": "refund of 90.0",