Skip to content

Commit

Permalink
[IMP] account_payment_sale: test performance improvement
Browse files Browse the repository at this point in the history
- Create setUpClass method
- Include context keys for avoiding mail operations overhead.
  • Loading branch information
josep-tecnativa authored and sebalix committed Sep 19, 2024
1 parent 5492b40 commit 4d0d8d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions account_payment_sale/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Expand Down
7 changes: 7 additions & 0 deletions account_payment_sale/tests/test_sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d0d8d3

Please sign in to comment.