2020-05-04 15:17:28 +02:00
|
|
|
# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
|
|
|
|
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
|
|
|
|
|
|
from odoo.tests.common import TransactionCase
|
|
|
|
|
|
|
|
|
|
|
|
class TestModule(TransactionCase):
|
|
|
|
def setUp(self):
|
|
|
|
super().setUp()
|
|
|
|
self.ACTemplate = self.env["account.chart.template"]
|
|
|
|
self.AATemplate = self.env["account.account.template"]
|
|
|
|
self.ATTemplate = self.env["account.tax.template"]
|
|
|
|
self.AFPTemplate = self.env["account.fiscal.position.template"]
|
2021-05-18 11:52:53 +02:00
|
|
|
self.AFPATemplate = self.env["account.fiscal.position.account.template"]
|
2020-05-04 15:17:28 +02:00
|
|
|
self.AFPTTemplate = self.env["account.fiscal.position.tax.template"]
|
|
|
|
|
2021-05-18 11:52:53 +02:00
|
|
|
self.template = self.ACTemplate.create(
|
|
|
|
{
|
|
|
|
"name": "Chart of Account",
|
|
|
|
"bank_account_code_prefix": "BNK",
|
|
|
|
"cash_account_code_prefix": "CSH",
|
|
|
|
"transfer_account_code_prefix": "TRSF",
|
|
|
|
"currency_id": self.env.ref("base.EUR").id,
|
|
|
|
}
|
|
|
|
)
|
2020-05-04 15:17:28 +02:00
|
|
|
|
2021-05-18 11:52:53 +02:00
|
|
|
self.account_template = self.AATemplate.create(
|
|
|
|
{
|
|
|
|
"name": "Account Template",
|
|
|
|
"code": "CODE",
|
2022-11-03 23:25:22 +01:00
|
|
|
"account_type": "asset_receivable",
|
2021-05-18 11:52:53 +02:00
|
|
|
"chart_template_id": self.template.id,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
self.tax_template = self.ATTemplate.create(
|
|
|
|
{
|
|
|
|
"name": "Tax Template",
|
|
|
|
"chart_template_id": self.template.id,
|
|
|
|
"amount": 10.0,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
self.fiscal_position = self.AFPTemplate.create(
|
|
|
|
{
|
|
|
|
"name": "Fiscal Position",
|
|
|
|
"chart_template_id": self.template.id,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
self.fiscal_position_account = self.AFPATemplate.create(
|
|
|
|
{
|
|
|
|
"account_src_id": self.account_template.id,
|
|
|
|
"account_dest_id": self.account_template.id,
|
|
|
|
"position_id": self.fiscal_position.id,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
self.fiscal_position_tax = self.AFPTTemplate.create(
|
|
|
|
{
|
|
|
|
"tax_src_id": self.tax_template.id,
|
|
|
|
"position_id": self.fiscal_position.id,
|
|
|
|
}
|
|
|
|
)
|
2020-05-04 15:17:28 +02:00
|
|
|
|
|
|
|
def test_tax_template(self):
|
|
|
|
self.tax_template.active = False
|
|
|
|
self.assertEqual(
|
2021-05-18 11:52:53 +02:00
|
|
|
self.fiscal_position_tax.active,
|
|
|
|
False,
|
|
|
|
"Disable Tax template should disable Fiscal Position Tax",
|
|
|
|
)
|
2020-05-04 15:17:28 +02:00
|
|
|
|
|
|
|
self.fiscal_position_tax.active = True
|
|
|
|
self.assertEqual(
|
2021-05-18 11:52:53 +02:00
|
|
|
self.tax_template.active,
|
|
|
|
True,
|
|
|
|
"Enable Fiscal Position Tax should enable Tax Template",
|
|
|
|
)
|
2020-05-04 15:17:28 +02:00
|
|
|
|
|
|
|
def test_account_template(self):
|
|
|
|
self.account_template.active = False
|
|
|
|
self.assertEqual(
|
2021-05-18 11:52:53 +02:00
|
|
|
self.fiscal_position_account.active,
|
|
|
|
False,
|
|
|
|
"Disable Account template should disable Fiscal Position Account",
|
|
|
|
)
|
2020-05-04 15:17:28 +02:00
|
|
|
|
|
|
|
self.fiscal_position_account.active = True
|
|
|
|
self.assertEqual(
|
2021-05-18 11:52:53 +02:00
|
|
|
self.account_template.active,
|
|
|
|
True,
|
|
|
|
"Enable Fiscal Position Account should enable Account Template",
|
|
|
|
)
|