Skip to content

[FIX] account: year-range sequences with asymmetric year widths - #3

Open
dnplkndll wants to merge 1 commit into
20.0from
20.0-fix-sequence-mixin-fiscalyear
Open

dnplkndll wants to merge 1 commit into
20.0from
20.0-fix-sequence-mixin-fiscalyear

Conversation

@dnplkndll

Copy link
Copy Markdown

One-operand fix in account.sequence.mixin. Opened against the fork's 20.0
mirror for review before anything goes to odoo/odoo.

The bug

_validate_fiscalyear_difference compares the incremented start year to the
parsed end year, but truncates to the width of the start year:

return self._truncate_year_to_length(int(start_year) + 1, len(start_year)) == int(end_year)

For JRNL/2015-16/ that is truncate(2016, 4) == 162016 == 16 → False, so
the name is no longer classified as a year-range sequence. Formats where both
components are the same width (2015-2016, 15-16) still pass, which is why the
breakage is easy to miss.

The method was extracted from an inline expression in c9103a6a10b8
(odoo#270582, "annual sequence number when fiscal year > 12 months"). The
19.0 original truncated to len(groupdict['year_end']) — the operand actually
being compared. This restores that.

User-visible effect

On a journal already numbering JRNL/2015-16/00001:

Move 19.0 / expected 20.0 today
next in period JRNL/2015-16/00002 JRNL/2015-16/00002
next period JRNL/2016-17/00001 JRNL/2015-16/00003
next year JRNL/2016-17/00002 JRNL/2015-17/00001

That third value is not a valid fiscal-year range at all.

Verification

Existing core coverage already catches it — no new test needed.
account:TestSequenceMixin.test_journal_sequence_format fails on 20.0 at
310a97e0 and passes on odoo:19.0.

  • TestSequenceMixin (25 tests): red before, green after.
  • Full account suite (1139 tests): 2 failed before → 0 failed after.

The other pre-existing failure was
TestAccountMoveReconcile.test_reconcile_special_mexican_workflow_2, which
asserts on line_ids list order and did not reproduce on rerun — unrelated
order-nondeterminism, untouched here.

Run on an arm64 build of the 20.0 branch (ubuntu:24.04 / Python 3.12 /
PostgreSQL 16), since no odoo:20.0 image or 20.0 nightly exists yet.

AI-assisted (Claude Code); every change reviewed, tested, and owned by the author.

`_validate_fiscalyear_difference` truncates the incremented start year to
`len(start_year)` before comparing it against the parsed end year. When the
two year components have different widths -- `JRNL/2015-16/00001`, the common
short-form fiscal-year notation -- that compares a four-digit year against a
two-digit one, never matches, and the name stops being recognised as a
year-range sequence.

On an existing `JRNL/2015-16/` journal the next move in the following period
is then numbered `JRNL/2015-16/00003` instead of rolling over to
`JRNL/2016-17/00001`, and the next year produces a malformed
`JRNL/2015-17/00001`.

The inline expression this method was extracted from in 19.0 truncated to
`len(year_end)`, which is the operand the result is compared against. Restore
that operand. Symmetric formats (`2015-2016`, `15-16`) were unaffected, which
is why only one of the twelve cases in
`TestSequenceMixin.test_journal_sequence_format` fails.

Introduced in c9103a6 (odoo#270582).

Assisted-by: Claude Opus 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant