From 4d0d8d35e6e583ee7eb375402d5661858fdb611c Mon Sep 17 00:00:00 2001 From: josep-tecnativa Date: Mon, 16 Oct 2023 12:34:55 +0200 Subject: [PATCH] [IMP] account_payment_sale: test performance improvement - Create setUpClass method - Include context keys for avoiding mail operations overhead. --- account_payment_sale/tests/common.py | 5 +++-- account_payment_sale/tests/test_sale_order.py | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) 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