[IMP] account_journal_lock_date: two dates per journal

- Change in journal the existing 'Lock date' by two dates, the same as in company.
- Add a wizard to allows a massive update of those dates for several journals at the same time.
This commit is contained in:
Ernesto Tejeda
2020-08-20 09:22:40 -04:00
committed by Zar21
parent 4bb9f2f493
commit 0774392e35
18 changed files with 467 additions and 108 deletions

View File

@@ -1,6 +1,7 @@
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import date
from odoo import api, models, _
from ..exceptions import JournalLockDateError
@@ -23,16 +24,30 @@ class AccountMove(models.Model):
self._check_lock_date()
return res
@api.multi
def _check_lock_date(self):
res = super(AccountMove, self)._check_lock_date()
if self.env['account.journal']._can_bypass_journal_lock_date():
res = super()._check_lock_date()
if self.env.context.get("bypass_journal_lock_date"):
return res
for move in self:
lock_date = move.journal_id.journal_lock_date
if lock_date and move.date <= lock_date:
raise JournalLockDateError(
_("You cannot add/modify entries prior to and "
"inclusive of the journal lock date %s") %
(lock_date, ))
if self.user_has_groups('account.group_account_manager'):
lock_date = move.journal_id.fiscalyear_lock_date or date.min
else:
lock_date = max(
move.journal_id.period_lock_date or date.min,
move.journal_id.fiscalyear_lock_date or date.min,
)
if move.date <= lock_date:
if self.user_has_groups('account.group_account_manager'):
message = _(
"You cannot add/modify entries for the journal '%s' "
"prior to and inclusive of the lock date %s"
) % (move.journal_id.display_name, lock_date)
else:
message = _(
"You cannot add/modify entries for the journal '%s' "
"prior to and inclusive of the lock date %s. "
"Check the Journal settings or ask someone "
"with the 'Adviser' role"
) % (move.journal_id.display_name, lock_date)
raise JournalLockDateError(message)
return res