Skip to content

[FIX] account_lock_to_date: fix reversed comparison in fiscalyear lock to date check - #2340

Open
SaraMohamedlorim wants to merge 2 commits into
OCA:17.0from
SaraMohamedlorim:fix-2334-lock-to-date-comparison-17
Open

[FIX] account_lock_to_date: fix reversed comparison in fiscalyear lock to date check#2340
SaraMohamedlorim wants to merge 2 commits into
OCA:17.0from
SaraMohamedlorim:fix-2334-lock-to-date-comparison-17

Conversation

@SaraMohamedlorim

Copy link
Copy Markdown

Description

Fixes #2334

The _check_lock_to_dates method in res_company.py had a reversed
comparison when validating the new fiscalyear_lock_to_date against
the previous one.

The error message states that the new lock to date for advisors must
be set after the previous lock to date, but the code was actually
raising a ValidationError when the new date was later than the
old one, and silently allowing the new date to be earlier than
(or equal to) the old one — the exact opposite of the intended and
documented behavior.

Before

if (
    old_fiscalyear_lock_to_date
    and fiscalyear_lock_to_date
    and fiscalyear_lock_to_date > old_fiscalyear_lock_to_date
):
    raise ValidationError(...)

After

if (
    old_fiscalyear_lock_to_date
    and fiscalyear_lock_to_date
    and fiscalyear_lock_to_date < old_fiscalyear_lock_to_date
):
    raise ValidationError(...)

Tests

Added two new test cases in test_account_lock_to_date_update.py:

  • test_02b_update_to_later_date_succeeds: confirms that moving the
    fiscalyear lock to date forward is now allowed.
  • test_02c_update_to_earlier_date_fails: confirms that moving the
    fiscalyear lock to date backward is correctly rejected.

All 7 existing tests plus the 2 new ones pass (0 failed, 0 errors).

@OCA-git-bot OCA-git-bot added series:17.0 mod:account_lock_to_date Module account_lock_to_date labels Jun 27, 2026
@SaraMohamedlorim

Copy link
Copy Markdown
Author

The CI failure in test_move_template_normal_with_tax_and_payment_terms
(module account_move_template) is unrelated to this PR — it appears to
be a pre-existing date-dependent test issue (off-by-one day on
date_maturity), not something my changes touch.

All 9 tests in account_lock_to_date (including the 2 new ones added
in this PR) pass successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:account_lock_to_date Module account_lock_to_date series:17.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants