Skip to content

Commit

Permalink
[IMP] account_lock_to_date: bypass functionality via context
Browse files Browse the repository at this point in the history
  • Loading branch information
kaynnan committed Sep 27, 2024
1 parent d0d8002 commit b81940c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
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 @@ -18,6 +18,8 @@ def _check_lock_to_dates(self):
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
if self.env.context.get("bypass_account_lock_to_date"):
continue
if is_advisor:
lock_to_date = advisor_lock_to_date or False
else:
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()

0 comments on commit b81940c

Please sign in to comment.