1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class SpreadsheetAccountGroupTest(AccountTestInvoicingCommon):
def test_fetch_account_no_group(self):
self.assertEqual(self.env["account.account"].get_account_group([]), [])
def test_fetch_account_one_group(self):
self.assertEqual(self.env["account.account"].get_account_group(['income_other']), [['450000']])
def test_group_with_no_account(self):
self.env['account.account']\
.search([('account_type', '=', 'income_other'), ('company_ids', '=', self.env.company.id)])\
.unlink()
self.assertEqual(self.env["account.account"].get_account_group(['income_other']), [[]])
def test_with_wrong_account_type_id(self):
self.assertEqual(self.env["account.account"].get_account_group([999999]), [[]])
def test_group_with_multiple_accounts(self):
self.env['account.account'].create({
'name': "test_group_with_multiple_accounts 1",
'account_type': 'income_other',
'code': '123',
})
self.env['account.account'].create({
'name': "test_group_with_multiple_accounts 2",
'account_type': 'income_other',
'code': '789',
})
self.assertEqual(
[sorted(x) for x in self.env['account.account'].get_account_group(['income_other'])],
[['123', '450000', '789']],
)
def test_response_is_ordered(self):
o1_codes_1, o1_codes_2 = self.env["account.account"].get_account_group(
["income", "income_other"]
)
o2_codes_2, o2_codes_1 = self.env["account.account"].get_account_group(
["income_other", "income"]
)
self.assertEqual(o1_codes_1, o2_codes_1)
self.assertEqual(o1_codes_2, o2_codes_2)
|