Skip to content
Snippets Groups Projects
account_period_close.py 1.7 KiB
Newer Older
# -*- coding: utf-8 -*-
##############################################################################
#
#    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
from odoo import fields, models
class AccountPeriodClose(models.TransientModel):
    """Wizard to close a period.
    """

    _name = "account.period.close"
    _description = "Period closure"

    validated = fields.Boolean(
        string="Check this box",
        help="Checking this box will confirm period closure.",
    )

    def close(self):
        """Method to close periods.
        """

        self.ensure_one()

        if self.validated:

            period_ids = self.env.context.get("active_ids", [])
                periods = self.env["account.period"].browse(period_ids)
                periods.write({"state": "done"})
        return {"type": "ir.actions.act_window_close"}