Newer
Older

Vincent Hatakeyama
committed
##############################################################################
#
# Accounting periods, for Odoo
# Copyright (C) 2018 XCG Consulting <http://odoo.consulting>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

Vincent Hatakeyama
committed
@odoo.tests.common.at_install(False)
@odoo.tests.common.post_install(True)
class Test(odoo.tests.TransactionCase):
"""Fiscal year & period creation tests.
"""

Vincent Hatakeyama
committed
def test_create_period(self):
fiscalyear = self.env["account.fiscalyear"].create(
{
"code": "something",
"name": "anything",
"date_stop": odoo.fields.Date.to_date("2017-12-31"),

Vincent Hatakeyama
committed
fiscalyear.create_period()
self.assertEqual(len(fiscalyear.period_ids), 12)
self.assertEqual(
fiscalyear.date_stop,
max(period.date_stop for period in fiscalyear.period_ids),
)

Vincent Hatakeyama
committed
self.assertEqual(
fiscalyear.date_start,
min(period.date_start for period in fiscalyear.period_ids),
)

Vincent Hatakeyama
committed
def test_create_period_change_fiscalyear_end(self):
self.env.user.company_id.write(
{"fiscalyear_last_month": "9", "fiscalyear_last_day": 20}
)
fiscalyear = self.env["account.fiscalyear"].create(
{
"code": "another",
"name": "more",
"date_stop": odoo.fields.Date.to_date("1977-09-20"),
}

Vincent Hatakeyama
committed
fiscalyear.create_period()
self.assertEqual(len(fiscalyear.period_ids), 12)
self.assertEqual(
fiscalyear.date_stop,
max(period.date_stop for period in fiscalyear.period_ids),
)

Vincent Hatakeyama
committed
self.assertEqual(
fiscalyear.date_start,
min(period.date_start for period in fiscalyear.period_ids),
)