diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 17:14:58 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 17:14:58 +0700 |
| commit | 1ca3b3df3421961caec3b747a364071c80f5c7da (patch) | |
| tree | 6778a1f0f3f9b4c6e26d6d87ccde16e24da6c9d6 /base_accounting_kit/wizard/account_lock_date.py | |
| parent | b57188be371d36d96caac4b8d65a40745c0e972c (diff) | |
initial commit
Diffstat (limited to 'base_accounting_kit/wizard/account_lock_date.py')
| -rw-r--r-- | base_accounting_kit/wizard/account_lock_date.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/base_accounting_kit/wizard/account_lock_date.py b/base_accounting_kit/wizard/account_lock_date.py new file mode 100644 index 0000000..7fcff94 --- /dev/null +++ b/base_accounting_kit/wizard/account_lock_date.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) +# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see <http://www.gnu.org/licenses/>. +# +############################################################################# +from odoo import api, fields, models, SUPERUSER_ID, _ +from odoo.exceptions import UserError + + +class AccountUpdateLockDate(models.TransientModel): + _name = 'account.lock.date' + _description = 'Lock date for accounting' + + company_id = fields.Many2one(comodel_name='res.company', string="Company", + required=True) + period_lock_date = fields.Date(string="Lock Date for Non-Advisers", + help="Only users with the 'Adviser' role can edit accounts prior to " + "and inclusive of this date. Use it for period locking inside an " + "open fiscal year, for example.") + fiscalyear_lock_date = fields.Date(string="Lock Date", + help="No users, including Advisers, can edit accounts prior to and " + "inclusive of this date. Use it for fiscal year locking for " + "example.") + + @api.model + def default_get(self, field_list): + res = super(AccountUpdateLockDate, self).default_get(field_list) + company = self.env.company + res.update({ + 'company_id': company.id, + 'period_lock_date': company.period_lock_date, + 'fiscalyear_lock_date': company.fiscalyear_lock_date, + }) + return res + + def _check_execute_allowed(self): + self.ensure_one() + has_adviser_group = self.env.user.has_group( + 'account.group_account_manager') + if not (has_adviser_group or self.env.uid == SUPERUSER_ID): + raise UserError(_("You are not allowed to execute this action.")) + + def execute(self): + self.ensure_one() + self._check_execute_allowed() + self.company_id.sudo().write({ + 'period_lock_date': self.period_lock_date, + 'fiscalyear_lock_date': self.fiscalyear_lock_date, + }) |
