2020-08-20 15:22:40 +02:00
|
|
|
# Copyright 2020 Tecnativa - Ernesto Tejeda
|
|
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
|
|
|
2020-10-08 00:28:42 +02:00
|
|
|
from odoo import SUPERUSER_ID, _, fields, models
|
2020-08-20 15:22:40 +02:00
|
|
|
from odoo.exceptions import UserError
|
|
|
|
|
|
|
|
|
|
|
|
class UpdateJournalLockDatesWizard(models.TransientModel):
|
2020-10-08 00:28:42 +02:00
|
|
|
_name = "update.journal.lock.dates.wizard"
|
|
|
|
_description = "Mass Update Journal Lock Dates Wizard"
|
2020-08-20 15:22:40 +02:00
|
|
|
|
|
|
|
period_lock_date = fields.Date(string="Lock Date for Non-Advisers")
|
|
|
|
fiscalyear_lock_date = fields.Date(string="Lock Date")
|
|
|
|
|
|
|
|
def _check_execute_allowed(self):
|
|
|
|
self.ensure_one()
|
2020-10-08 00:28:42 +02:00
|
|
|
has_adviser_group = self.env.user.has_group("account.group_account_manager")
|
2020-08-20 15:22:40 +02:00
|
|
|
if not (has_adviser_group or self.env.uid == SUPERUSER_ID):
|
|
|
|
raise UserError(_("You are not allowed to execute this action."))
|
|
|
|
|
|
|
|
def action_update_lock_dates(self):
|
|
|
|
self.ensure_one()
|
|
|
|
self._check_execute_allowed()
|
2020-10-08 00:28:42 +02:00
|
|
|
self.env["account.journal"].browse(self.env.context.get("active_ids")).write(
|
|
|
|
{
|
|
|
|
"period_lock_date": self.period_lock_date,
|
|
|
|
"fiscalyear_lock_date": self.fiscalyear_lock_date,
|
|
|
|
}
|
|
|
|
)
|