Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
2
account_journal_lock_date/models/__init__.py
Executable file
2
account_journal_lock_date/models/__init__.py
Executable file
@@ -0,0 +1,2 @@
|
||||
from . import account_journal
|
||||
from . import account_move
|
||||
22
account_journal_lock_date/models/account_journal.py
Executable file
22
account_journal_lock_date/models/account_journal.py
Executable file
@@ -0,0 +1,22 @@
|
||||
# Copyright 2017 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountJournal(models.Model):
|
||||
_inherit = "account.journal"
|
||||
|
||||
fiscalyear_lock_date = fields.Date(
|
||||
string="Lock Date",
|
||||
help="No users, including Advisers, can edit accounts prior "
|
||||
"to and inclusive of this date for this journal. Use it "
|
||||
"for fiscal year locking for this journal, for example.",
|
||||
)
|
||||
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 for this journal. "
|
||||
"Use it for period locking inside an open fiscal year "
|
||||
"for this journal, for example.",
|
||||
)
|
||||
45
account_journal_lock_date/models/account_move.py
Executable file
45
account_journal_lock_date/models/account_move.py
Executable file
@@ -0,0 +1,45 @@
|
||||
# Copyright 2017 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tools.misc import format_date
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = "account.move"
|
||||
|
||||
def _check_fiscal_lock_dates(self):
|
||||
res = super()._check_fiscal_lock_dates()
|
||||
if self.env.context.get("bypass_journal_lock_date"):
|
||||
return res
|
||||
|
||||
date_min = fields.date.min
|
||||
for move in self:
|
||||
if self.env.user.has_group("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:
|
||||
lock_date = format_date(self.env, lock_date)
|
||||
if self.env.user.has_group("account.group_account_manager"):
|
||||
message = self.env._(
|
||||
"You cannot add/modify entries for the journal '%(journal)s' "
|
||||
"prior to and inclusive of the lock date %(journal_date)s",
|
||||
journal=move.journal_id.display_name,
|
||||
journal_date=lock_date,
|
||||
)
|
||||
else:
|
||||
message = self.env._(
|
||||
"You cannot add/modify entries for the journal '%(journal)s' "
|
||||
"prior to and inclusive of the lock date %(journal_date)s. "
|
||||
"Check the Journal settings or ask someone "
|
||||
"with the 'Adviser' role",
|
||||
journal=move.journal_id.display_name,
|
||||
journal_date=lock_date,
|
||||
)
|
||||
raise UserError(message)
|
||||
return res
|
||||
Reference in New Issue
Block a user