Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][IMP] account_lock_to_date: bypass functionality via context #1942

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions account_lock_to_date/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def _check_lock_to_dates(self):
Other users will also be restricted by the period_lock_to_date.
"""
is_advisor = self.user_has_groups("account.group_account_manager")
if self.env.context.get("bypass_account_lock_to_date"):
return
for move in self:
advisor_lock_to_date = move.company_id.fiscalyear_lock_to_date
user_lock_to_date = move.company_id.period_lock_to_date
Expand Down
10 changes: 10 additions & 0 deletions account_lock_to_date/tests/test_account_lock_to_date_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,13 @@ def test_05_lock_period_with_draft_moves(self):
with self.assertRaises(ValidationError):
self.company.period_lock_to_date = "2900-01-01"
self.company.fiscalyear_lock_to_date = "2900-02-01"

def test_06_lock_period_with_bypass(self):
"""We test that journal entries can be posted after the locked date
when the bypass option is enabled."""
self.company.period_lock_to_date = "2900-01-01"
self.company.fiscalyear_lock_to_date = "2900-02-01"
move = self.create_account_move("2900-01-01").with_context(
bypass_account_lock_to_date=True
)
move.with_user(self.demo_user.id).action_post()
Loading