|
4 | 4 |
|
5 | 5 | from datetime import date, timedelta
|
6 | 6 |
|
| 7 | +from odoo.tests import tagged |
7 | 8 | from odoo.tests.common import TransactionCase
|
8 | 9 |
|
9 | 10 |
|
| 11 | +@tagged("-at_install", "post_install") |
10 | 12 | 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 |
17 | 29 | )
|
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 |
20 | 32 | )
|
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")], |
23 | 35 | limit=1,
|
24 | 36 | )
|
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")], |
27 | 39 | limit=1,
|
28 | 40 | )
|
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)] |
31 | 43 | )
|
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( |
35 | 47 | [("code", "=", "account.cash.deposit")]
|
36 | 48 | )
|
37 |
| - self.order_seq = self.env["ir.sequence"].search( |
| 49 | + cls.order_seq = cls.env["ir.sequence"].search( |
38 | 50 | [("code", "=", "account.cash.order")]
|
39 | 51 | )
|
40 | 52 |
|
|
0 commit comments