diff --git a/account_lock_to_date/models/account_move.py b/account_lock_to_date/models/account_move.py index d61cc7575dc3..074f43b6a20d 100644 --- a/account_lock_to_date/models/account_move.py +++ b/account_lock_to_date/models/account_move.py @@ -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: diff --git a/account_lock_to_date/tests/test_account_lock_to_date_update.py b/account_lock_to_date/tests/test_account_lock_to_date_update.py index d6bdd2c2e00d..29fe71acb81f 100644 --- a/account_lock_to_date/tests/test_account_lock_to_date_update.py +++ b/account_lock_to_date/tests/test_account_lock_to_date_update.py @@ -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()