From fb9c2edadd7ac8d4464f187574374dc4abdcff6e Mon Sep 17 00:00:00 2001 From: josep-tecnativa Date: Mon, 16 Oct 2023 11:09:33 +0200 Subject: [PATCH 1/5] [IMP] account_bank_statement_reopen_skip_undo_reconciliation: test performance improvement - Create setUpClass method - Include context keys for avoiding mail operations overhead. --- .../tests/test_account_bank_statement.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/tests/test_account_bank_statement.py b/account_bank_statement_reopen_skip_undo_reconciliation/tests/test_account_bank_statement.py index 539aefd7..7e6f1609 100644 --- a/account_bank_statement_reopen_skip_undo_reconciliation/tests/test_account_bank_statement.py +++ b/account_bank_statement_reopen_skip_undo_reconciliation/tests/test_account_bank_statement.py @@ -11,6 +11,20 @@ from odoo.addons.account.tests.test_account_bank_statement import ( @tagged("post_install", "-at_install") class TestAccountBankStatementLine(TestAccountBankStatementCommon): + @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, + ) + ) + def test_button_undo_reconciliation(self): statement = self.env["account.bank.statement"].create( { From dcca385cde33e1eb3406bf2f7cc081b66e4449c8 Mon Sep 17 00:00:00 2001 From: josep-tecnativa Date: Mon, 16 Oct 2023 11:10:11 +0200 Subject: [PATCH 2/5] [IMP] account_move_reconcile_forbid_cancel: test performance improvement - Include context keys for avoiding mail operations overhead. --- .../tests/test_account_move_reconcile_forbid_cancel.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/account_move_reconcile_forbid_cancel/tests/test_account_move_reconcile_forbid_cancel.py b/account_move_reconcile_forbid_cancel/tests/test_account_move_reconcile_forbid_cancel.py index f5f7c92e..f88f8f71 100644 --- a/account_move_reconcile_forbid_cancel/tests/test_account_move_reconcile_forbid_cancel.py +++ b/account_move_reconcile_forbid_cancel/tests/test_account_move_reconcile_forbid_cancel.py @@ -10,6 +10,16 @@ class TestAccountMoveReconcileForbidCancel(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["account.journal"].create( {"name": "Bank Journal", "code": "BANK", "type": "bank"} ) From e2e49d4c04af4d058267848c3ce55b3f56ac71d6 Mon Sep 17 00:00:00 2001 From: josep-tecnativa Date: Mon, 16 Oct 2023 11:13:57 +0200 Subject: [PATCH 3/5] [IMP] account_reconcile_payment_order: test performance improvement - Include context keys for avoiding mail operations overhead. --- .../tests/test_account_reconcile_payment_order.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/account_reconcile_payment_order/tests/test_account_reconcile_payment_order.py b/account_reconcile_payment_order/tests/test_account_reconcile_payment_order.py index 5a54294d..397f4200 100644 --- a/account_reconcile_payment_order/tests/test_account_reconcile_payment_order.py +++ b/account_reconcile_payment_order/tests/test_account_reconcile_payment_order.py @@ -14,6 +14,16 @@ class TestAccountReconcilePaymentOrder(TestPaymentOrderInboundBase): @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.widget_obj = cls.env["account.reconciliation.widget"] cls.bank_journal = cls.env["account.journal"].create( {"name": "Test bank journal", "type": "bank"} From d490df5e19eafcf68af6200dbee351ac79b58508 Mon Sep 17 00:00:00 2001 From: josep-tecnativa Date: Mon, 16 Oct 2023 11:15:42 +0200 Subject: [PATCH 4/5] [IMP] account_reconciliation_widget: test performance improvement - Include context keys for avoiding mail operations overhead. --- .../tests/test_reconciliation_widget.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/account_reconciliation_widget/tests/test_reconciliation_widget.py b/account_reconciliation_widget/tests/test_reconciliation_widget.py index b2cb8f45..87ba77dc 100644 --- a/account_reconciliation_widget/tests/test_reconciliation_widget.py +++ b/account_reconciliation_widget/tests/test_reconciliation_widget.py @@ -65,6 +65,16 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): @classmethod def setUpClass(cls, chart_template_ref=None): super().setUpClass(chart_template_ref=chart_template_ref) + 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.acc_bank_stmt_model = cls.env["account.bank.statement"] cls.acc_bank_stmt_line_model = cls.env["account.bank.statement.line"] From 333bcdddbfff5f498b77d2b129f37eb41a038d9d Mon Sep 17 00:00:00 2001 From: josep-tecnativa Date: Mon, 16 Oct 2023 11:18:59 +0200 Subject: [PATCH 5/5] [IMP] account_reconciliation_widget_due_date: test performance improvement - Switch to setUpClass for avoiding repeat the same setup for each test. - Include context keys for avoiding mail operations overhead. --- ..._account_reconciliation_widget_date_due.py | 46 ++++++++++++------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/account_reconciliation_widget_due_date/tests/test_account_reconciliation_widget_date_due.py b/account_reconciliation_widget_due_date/tests/test_account_reconciliation_widget_date_due.py index 36601036..fef62935 100644 --- a/account_reconciliation_widget_due_date/tests/test_account_reconciliation_widget_date_due.py +++ b/account_reconciliation_widget_due_date/tests/test_account_reconciliation_widget_date_due.py @@ -7,50 +7,62 @@ from odoo.tests.common import Form, TransactionCase class TestAccountReconciliationWidgetDueDate(TransactionCase): - def setUp(self): - super().setUp() - self.company = self.env.ref("base.main_company") - self.journal = self.env["account.journal"].create( + @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.company = cls.env.ref("base.main_company") + cls.journal = cls.env["account.journal"].create( {"name": "Test journal bank", "type": "bank", "code": "BANK-TEST"} ) - self.account = self.env["account.account"].create( + cls.account = cls.env["account.account"].create( { "name": "Account Receivable", "code": "AR", - "user_type_id": self.env.ref("account.data_account_type_receivable").id, + "user_type_id": cls.env.ref("account.data_account_type_receivable").id, "reconcile": True, } ) - self.partner_a = self.env["res.partner"].create( + cls.partner_a = cls.env["res.partner"].create( { "name": "Partner Test A", - "property_account_receivable_id": self.account.id, + "property_account_receivable_id": cls.account.id, } ) - self.partner_b = self.partner_a.copy({"name": "Partner Test B"}) - self.partner_c = self.partner_a.copy({"name": "Partner Test C"}) - self.statement = self._create_account_bank_statement() + cls.partner_b = cls.partner_a.copy({"name": "Partner Test B"}) + cls.partner_c = cls.partner_a.copy({"name": "Partner Test C"}) + cls.statement = cls._create_account_bank_statement() - def _create_account_bank_statement(self): - statement_form = Form(self.env["account.bank.statement"]) - statement_form.journal_id = self.journal + @classmethod + def _create_account_bank_statement(cls): + statement_form = Form(cls.env["account.bank.statement"]) + statement_form.journal_id = cls.journal statement_form.date = date(2021, 3, 1) statement_form.balance_end_real = 600.00 with statement_form.line_ids.new() as line_form: line_form.date = "2021-01-01" line_form.payment_ref = "LINE_A" - line_form.partner_id = self.partner_a + line_form.partner_id = cls.partner_a line_form.amount = 100.00 with statement_form.line_ids.new() as line_form: line_form.date = "2021-02-01" line_form.date_due = "2021-02-05" line_form.payment_ref = "LINE_B" - line_form.partner_id = self.partner_b + line_form.partner_id = cls.partner_b line_form.amount = 200.00 with statement_form.line_ids.new() as line_form: line_form.date = "2021-03-01" line_form.payment_ref = "LINE_C" - line_form.partner_id = self.partner_c + line_form.partner_id = cls.partner_c line_form.amount = 300.00 return statement_form.save()