diff --git a/account_banking_mandate/tests/test_invoice_mandate.py b/account_banking_mandate/tests/test_invoice_mandate.py index e29058f488e1..7f62dbd27b04 100644 --- a/account_banking_mandate/tests/test_invoice_mandate.py +++ b/account_banking_mandate/tests/test_invoice_mandate.py @@ -8,6 +8,7 @@ from odoo.tests.common import TransactionCase from odoo.addons.account.models.account_payment_method import AccountPaymentMethod +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT class TestInvoiceMandate(TransactionCase): @@ -192,112 +193,105 @@ def test_invoice_constrains(self): with self.assertRaises(UserError): invoice.mandate_id = mandate_2 - def _create_res_partner(self, name): - return self.env["res.partner"].create({"name": name}) + @classmethod + def _create_res_partner(cls, name): + return cls.env["res.partner"].create({"name": name}) - def _create_res_bank(self, name, bic, city, country): - return self.env["res.bank"].create( + @classmethod + def _create_res_bank(cls, name, bic, city, country): + return cls.env["res.bank"].create( {"name": name, "bic": bic, "city": city, "country": country.id} ) - def setUp(self): - res = super(TestInvoiceMandate, self).setUp() - self.company = self.env.ref("base.main_company") - - self.partner = self._create_res_partner("Peter with ACME Bank") - self.acme_bank = self._create_res_bank( - "ACME Bank", "GEBABEBB03B", "Charleroi", self.env.ref("base.be") + @classmethod + def setUpClass(cls): + res = super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) + cls.company = cls.env.ref("base.main_company") + cls.partner = cls._create_res_partner("Peter with ACME Bank") + cls.acme_bank = cls._create_res_bank( + "ACME Bank", "GEBABEBB03B", "Charleroi", cls.env.ref("base.be") ) - - bank_account = self.env["res.partner.bank"].create( + bank_account = cls.env["res.partner.bank"].create( { "acc_number": "0023032234211123", - "partner_id": self.partner.id, - "bank_id": self.acme_bank.id, - "company_id": self.company.id, + "partner_id": cls.partner.id, + "bank_id": cls.acme_bank.id, + "company_id": cls.company.id, } ) - - self.company_2 = self.env["res.company"].create({"name": "Company 2"}) - - self.mandate = self.env["account.banking.mandate"].create( + cls.company_2 = cls.env["res.company"].create({"name": "Company 2"}) + cls.mandate = cls.env["account.banking.mandate"].create( { "partner_bank_id": bank_account.id, "signature_date": "2015-01-01", - "company_id": self.company.id, + "company_id": cls.company.id, } ) - - self.mandate.validate() - - self.mode_inbound_acme = self.env["account.payment.mode"].create( + cls.mandate.validate() + cls.mode_inbound_acme = cls.env["account.payment.mode"].create( { "name": "Inbound Credit ACME Bank", - "company_id": self.company.id, + "company_id": cls.company.id, "bank_account_link": "variable", - "payment_method_id": self.env.ref( + "payment_method_id": cls.env.ref( "account.account_payment_method_manual_in" ).id, } ) - bank_journal = self.env["account.journal"].search( + bank_journal = cls.env["account.journal"].search( [ ("type", "=", "bank"), - ("company_id", "=", self.company.id), + ("company_id", "=", cls.company.id), ], limit=1, ) - self.mode_inbound_acme.variable_journal_ids = bank_journal - self.mode_inbound_acme.payment_method_id.mandate_required = True - self.mode_inbound_acme.payment_order_ok = True - - self.partner.customer_payment_mode_id = self.mode_inbound_acme - - self.invoice_account = self.env["account.account"].search( + cls.mode_inbound_acme.variable_journal_ids = bank_journal + cls.mode_inbound_acme.payment_method_id.mandate_required = True + cls.mode_inbound_acme.payment_order_ok = True + cls.partner.customer_payment_mode_id = cls.mode_inbound_acme + cls.invoice_account = cls.env["account.account"].search( [ ("account_type", "=", "asset_receivable"), - ("company_id", "=", self.company.id), + ("company_id", "=", cls.company.id), ], limit=1, ) invoice_line_account = ( - self.env["account.account"] + cls.env["account.account"] .search( [ ("account_type", "=", "expense"), - ("company_id", "=", self.company.id), + ("company_id", "=", cls.company.id), ], limit=1, ) .id ) - invoice_vals = [ ( 0, 0, { - "product_id": self.env.ref("product.product_product_4").id, + "product_id": cls.env.ref("product.product_product_4").id, "quantity": 1.0, "account_id": invoice_line_account, "price_unit": 200.00, }, ) ] - - self.invoice = self.env["account.move"].create( + cls.invoice = cls.env["account.move"].create( { - "partner_id": self.partner.id, + "partner_id": cls.partner.id, "move_type": "out_invoice", - "company_id": self.company.id, - "journal_id": self.env["account.journal"] + "company_id": cls.company.id, + "journal_id": cls.env["account.journal"] .search( - [("type", "=", "sale"), ("company_id", "=", self.company.id)], + [("type", "=", "sale"), ("company_id", "=", cls.company.id)], limit=1, ) .id, "invoice_line_ids": invoice_vals, } ) - return res diff --git a/account_banking_mandate/tests/test_mandate.py b/account_banking_mandate/tests/test_mandate.py index d383ac37c02d..4328c90aafe1 100644 --- a/account_banking_mandate/tests/test_mandate.py +++ b/account_banking_mandate/tests/test_mandate.py @@ -7,22 +7,27 @@ from odoo.exceptions import UserError, ValidationError from odoo.tests.common import TransactionCase +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + class TestMandate(TransactionCase): - def setUp(self): - super(TestMandate, self).setUp() - self.company = self.env.company - self.company_2 = self.env["res.company"].create({"name": "company 2"}) - self.company_2.partner_id.company_id = self.company_2.id - self.bank_account = self.env.ref("account_payment_mode.res_partner_12_iban") - self.bank_account.partner_id.company_id = self.company.id - self.mandate = self.env["account.banking.mandate"].create( + @classmethod + def setUpClass(cls): + res = super(TestMandate, cls).setUpClass() + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) + cls.company = cls.env.ref("base.main_company") + cls.company_2 = cls.env["res.company"].create({"name": "Company 2"}) + cls.company_2.partner_id.company_id = cls.company_2.id + cls.bank_account = cls.env.ref("account_payment_mode.res_partner_12_iban") + cls.bank_account.partner_id.company_id = cls.company.id + cls.mandate = cls.env["account.banking.mandate"].create( { - "partner_bank_id": self.bank_account.id, + "partner_bank_id": cls.bank_account.id, "signature_date": "2015-01-01", - "company_id": self.company.id, + "company_id": cls.company.id, } ) + return res def test_mandate_01(self): self.assertEqual(self.mandate.state, "draft") diff --git a/account_banking_mandate_contact/tests/test_account_payment_order.py b/account_banking_mandate_contact/tests/test_account_payment_order.py index 22768bc655aa..9d1837ee33f5 100644 --- a/account_banking_mandate_contact/tests/test_account_payment_order.py +++ b/account_banking_mandate_contact/tests/test_account_payment_order.py @@ -4,21 +4,14 @@ from odoo import fields from odoo.tests.common import Form, TransactionCase +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + class TestAccountPaymentOrder(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() - cls.env = cls.env( - context=dict( - cls.env.context, - mail_create_nolog=True, - mail_create_nosubscribe=True, - mail_notrack=True, - no_reset_password=True, - tracking_disable=True, - ) - ) + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) cls.partner = cls.env["res.partner"].create({"name": "Test Partner"}) cls.product = cls.env["product.product"].create({"name": "Test product"}) cls.partner_bank_core = cls._create_res_partner_bank("N-CORE") diff --git a/account_banking_sepa_credit_transfer/tests/test_sct.py b/account_banking_sepa_credit_transfer/tests/test_sct.py index aba156811388..514fcd985a93 100644 --- a/account_banking_sepa_credit_transfer/tests/test_sct.py +++ b/account_banking_sepa_credit_transfer/tests/test_sct.py @@ -11,11 +11,14 @@ from odoo.exceptions import UserError from odoo.tests.common import TransactionCase +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + class TestSCT(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) cls.account_model = cls.env["account.account"] cls.move_model = cls.env["account.move"] cls.journal_model = cls.env["account.journal"] diff --git a/account_banking_sepa_direct_debit/tests/test_mandate.py b/account_banking_sepa_direct_debit/tests/test_mandate.py index eff7e8ea82d2..090c583bb5e4 100644 --- a/account_banking_sepa_direct_debit/tests/test_mandate.py +++ b/account_banking_sepa_direct_debit/tests/test_mandate.py @@ -50,11 +50,22 @@ def test_action_mandate_send(self): self.assertEqual(self.mandate.state, "draft") self.assertTrue(self.mandate.is_sent) - def setUp(self): - res = super().setUp() - self.partner = self.env.ref("base.res_partner_12") - bank_account = self.env.ref("account_payment_mode.res_partner_12_iban") - self.mandate = self.env["account.banking.mandate"].create( + @classmethod + def setUpClass(cls): + res = super().setUpClass() + cls.env = cls.env( + context=dict( + cls.env.context, + mail_create_nolog=True, + mail_create_nosubscribe=True, + mail_notrack=True, + no_reset_password=True, + tracking_disable=True, + ) + ) + cls.partner = cls.env.ref("base.res_partner_12") + bank_account = cls.env.ref("account_payment_mode.res_partner_12_iban") + cls.mandate = cls.env["account.banking.mandate"].create( { "partner_bank_id": bank_account.id, "format": "sepa", diff --git a/account_banking_sepa_direct_debit/tests/test_sdd.py b/account_banking_sepa_direct_debit/tests/test_sdd.py index aa2fdaeb3581..49fdd7cc5394 100644 --- a/account_banking_sepa_direct_debit/tests/test_sdd.py +++ b/account_banking_sepa_direct_debit/tests/test_sdd.py @@ -10,11 +10,14 @@ from odoo.tests.common import TransactionCase from odoo.tools import float_compare +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + class TestSDDBase(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) cls.company_B = cls.env["res.company"].create({"name": "Company B"}) cls.account_payable_company_B = cls.env["account.account"].create( { diff --git a/account_payment_mode/tests/test_account_payment_mode.py b/account_payment_mode/tests/test_account_payment_mode.py index db23e176e6f3..d2be3c7af086 100644 --- a/account_payment_mode/tests/test_account_payment_mode.py +++ b/account_payment_mode/tests/test_account_payment_mode.py @@ -4,12 +4,14 @@ from odoo.exceptions import UserError, ValidationError from odoo.tests.common import TransactionCase +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + class TestAccountPaymentMode(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() - cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) cls.res_users_model = cls.env["res.users"] cls.journal_model = cls.env["account.journal"] diff --git a/account_payment_order/tests/test_bank.py b/account_payment_order/tests/test_bank.py index d5d78bf8155d..218f96b781ac 100644 --- a/account_payment_order/tests/test_bank.py +++ b/account_payment_order/tests/test_bank.py @@ -4,8 +4,15 @@ from odoo.exceptions import ValidationError from odoo.tests.common import TransactionCase +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + class TestBank(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) + def test_bank(self): bank = self.env["res.bank"].search([], limit=1) self.assertTrue(bank) diff --git a/account_payment_order/tests/test_payment_mode.py b/account_payment_order/tests/test_payment_mode.py index 51bce1e70324..f1f346cb33d7 100644 --- a/account_payment_order/tests/test_payment_mode.py +++ b/account_payment_order/tests/test_payment_mode.py @@ -18,8 +18,8 @@ def setUpClass(cls): AccountPaymentMethod._get_payment_method_information ) - def _get_payment_method_information(self): - res = Method_get_payment_method_information(self) + def _get_payment_method_information(cls): + res = Method_get_payment_method_information(cls) res["IN"] = {"mode": "multi", "domain": [("type", "=", "bank")]} res["IN2"] = {"mode": "multi", "domain": [("type", "=", "bank")]} res["electronic_out"] = {"mode": "multi", "domain": [("type", "=", "bank")]} diff --git a/account_payment_partner/tests/test_account_payment_partner.py b/account_payment_partner/tests/test_account_payment_partner.py index 517746b275a7..ec8dcf20d3d5 100644 --- a/account_payment_partner/tests/test_account_payment_partner.py +++ b/account_payment_partner/tests/test_account_payment_partner.py @@ -7,12 +7,14 @@ from odoo.fields import Date from odoo.tests.common import Form, TransactionCase +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + class TestAccountPaymentPartner(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() - cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) cls.res_users_model = cls.env["res.users"] cls.move_model = cls.env["account.move"] diff --git a/account_payment_sale/tests/common.py b/account_payment_sale/tests/common.py index a2d6ae887825..e49c8c7bd6cd 100644 --- a/account_payment_sale/tests/common.py +++ b/account_payment_sale/tests/common.py @@ -3,13 +3,14 @@ from odoo.tests.common import TransactionCase +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + class CommonTestCase(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() - cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) - + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) cls.bank = cls.env["res.partner.bank"].create( {"acc_number": "test", "partner_id": cls.env.user.company_id.partner_id.id} ) diff --git a/account_payment_sale/tests/test_sale_order.py b/account_payment_sale/tests/test_sale_order.py index fcaf0f0faa28..57abac429201 100644 --- a/account_payment_sale/tests/test_sale_order.py +++ b/account_payment_sale/tests/test_sale_order.py @@ -3,10 +3,17 @@ from odoo.tests import Form +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + from .common import CommonTestCase class TestSaleOrder(CommonTestCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) + def create_sale_order(self, payment_mode=None): with Form(self.env["sale.order"]) as sale_form: sale_form.partner_id = self.base_partner