Skip to content

Commit 628d362

Browse files
committed
Merge PR #2046 into 16.0
Signed-off-by pedrobaeza
2 parents 7643d06 + 33c491f commit 628d362

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

account_cash_deposit/tests/test_cash_deposit.py

+30-18
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,49 @@
44

55
from datetime import date, timedelta
66

7+
from odoo.tests import tagged
78
from odoo.tests.common import TransactionCase
89

910

11+
@tagged("-at_install", "post_install")
1012
class TestAccountCashDeposit(TransactionCase):
11-
def setUp(self):
12-
super().setUp()
13-
self.company = self.env.ref("base.main_company")
14-
self.currency = self.company.currency_id
15-
self.cash_journal = self.env["account.journal"].search(
16-
[("type", "=", "cash"), ("company_id", "=", self.company.id)], limit=1
13+
@classmethod
14+
def setUpClass(cls):
15+
super().setUpClass()
16+
if not cls.env.company.chart_template_id:
17+
# Load a CoA if there's none in current company
18+
coa = cls.env.ref("l10n_generic_coa.configurable_chart_template", False)
19+
if not coa:
20+
# Load the first available CoA
21+
coa = cls.env["account.chart.template"].search(
22+
[("visible", "=", True)], limit=1
23+
)
24+
coa.try_loading(company=cls.env.company, install_demo=False)
25+
cls.company = cls.env.company
26+
cls.currency = cls.company.currency_id
27+
cls.cash_journal = cls.env["account.journal"].search(
28+
[("type", "=", "cash"), ("company_id", "=", cls.company.id)], limit=1
1729
)
18-
self.bank_journal = self.env["account.journal"].search(
19-
[("type", "=", "bank"), ("company_id", "=", self.company.id)], limit=1
30+
cls.bank_journal = cls.env["account.journal"].search(
31+
[("type", "=", "bank"), ("company_id", "=", cls.company.id)], limit=1
2032
)
21-
self.cash_unit_note = self.env["cash.unit"].search(
22-
[("currency_id", "=", self.currency.id), ("cash_type", "=", "note")],
33+
cls.cash_unit_note = cls.env["cash.unit"].search(
34+
[("currency_id", "=", cls.currency.id), ("cash_type", "=", "note")],
2335
limit=1,
2436
)
25-
self.cash_unit_coinroll = self.env["cash.unit"].search(
26-
[("currency_id", "=", self.currency.id), ("cash_type", "=", "coinroll")],
37+
cls.cash_unit_coinroll = cls.env["cash.unit"].search(
38+
[("currency_id", "=", cls.currency.id), ("cash_type", "=", "coinroll")],
2739
limit=1,
2840
)
29-
self.all_cash_units = self.env["cash.unit"].search(
30-
[("currency_id", "=", self.currency.id)]
41+
cls.all_cash_units = cls.env["cash.unit"].search(
42+
[("currency_id", "=", cls.currency.id)]
3143
)
32-
self.date = date.today()
33-
self.yesterday = date.today() - timedelta(days=1)
34-
self.deposit_seq = self.env["ir.sequence"].search(
44+
cls.date = date.today()
45+
cls.yesterday = date.today() - timedelta(days=1)
46+
cls.deposit_seq = cls.env["ir.sequence"].search(
3547
[("code", "=", "account.cash.deposit")]
3648
)
37-
self.order_seq = self.env["ir.sequence"].search(
49+
cls.order_seq = cls.env["ir.sequence"].search(
3850
[("code", "=", "account.cash.order")]
3951
)
4052

0 commit comments

Comments
 (0)