Skip to content
Snippets Groups Projects
test_account_fiscalyear.py 2.53 KiB
Newer Older
##############################################################################
#
#    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/>.
#
##############################################################################
Houzefa Abbasbhay's avatar
Houzefa Abbasbhay committed

import odoo.fields
import odoo.tests
Houzefa Abbasbhay's avatar
Houzefa Abbasbhay committed
@odoo.tests.common.at_install(False)
@odoo.tests.common.post_install(True)
class Test(odoo.tests.TransactionCase):
    """Fiscal year & period creation tests.
    """

        fiscalyear = self.env["account.fiscalyear"].create(
            {
                "code": "something",
                "name": "anything",
Houzefa Abbasbhay's avatar
Houzefa Abbasbhay committed
                "date_stop": odoo.fields.Date.to_date("2017-12-31"),
        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),
        )
            min(period.date_start for period in fiscalyear.period_ids),
        )

    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(
Houzefa Abbasbhay's avatar
Houzefa Abbasbhay committed
            {
                "code": "another",
                "name": "more",
                "date_stop": odoo.fields.Date.to_date("1977-09-20"),
            }
        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),
        )
            min(period.date_start for period in fiscalyear.period_ids),
        )