Repository navigation
[FIX] hr: backfill date_version for migrated contracts - #6064
Open
muhammadali124 wants to merge 1 commit into
Open
muhammadali124 wants to merge 1 commit into
muhammadali124 wants to merge 1 commit into
Conversation
muhammadali124
force-pushed
the
fix-hr-version-date-version-migration
branch
2 times, most recently
from
October 19, 2026 12:50
6a5223a to
19ccc70
Compare
hbrunn
approved these changes
Oct 20, 2026
hbrunn
requested changes
Oct 20, 2026
hbrunn
left a comment
Member
There was a problem hiding this comment.
this fails if hr_contract wasn't installed, so please make it conditional on contract_date_start existing
Author
|
@hbrunn Thanks for pointing out! I have gated it behind a condition. |
Member
|
Please rebase and squash the commits into one. |
The hr_contract -> hr.version migration never backfilled the new required date_version column on the "has a prior contract" branch, unlike the sibling "no prior contract" branch which sets it from create_date. It was left at today's date for every migrated employee, which breaks hr.version._is_overlapping_period for any pre-migration period. Backfill date_version from contract_date_start, gated on contract_date_start existing (only present when hr_contract was installed).
muhammadali124
force-pushed
the
fix-hr-version-date-version-migration
branch
from
October 20, 2026 07:39
88a68d4 to
ef86540
Compare
hbrunn
approved these changes
Oct 23, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
hr_contract->hr.versiontable rename produceshr.versionrowswhose
date_versioncolumn never existed on the old table. When thenew,
required=Truecolumn gets added by the ORM schema sync, it isleft at its Python-declared default (
fields.Date.today) for everyconverted contract - the date the migration itself happened to run,
not anything derived from the contract's real data.
This matters because
hr.version._compute_datescomputes:Since
date_versionends up pinned to the migration date for everymigrated employee,
date_startresolves to the migration date too -overriding the real, original contract start date entirely for this
purpose.
hr.version._is_overlapping_period, used byhr.payslip._get_employee_contracts()duringcompute_sheet(), thensilently excludes the contract for any payslip whose period is
earlier than the migration date:
The practical effect: after an 18.0 -> 19.0 upgrade, calling
compute_sheet()on any pre-existing payslip dated before themigration (regardless of its state - draft, verify, or done) silently
wipes its lines down to zero, with no error raised anywhere in the
chain. Confirmed this is not narrow - on a real migrated database with
~3,900 employees, essentially the entire
hr_versiontable (3,932 of3,934 rows) ended up with
date_versionpinned to the single date themigration ran, and all ~3,100 pre-migration payslips (draft, verify,
and done combined) are affected.
Fix
Backfill
date_versionfromcontract_date_startfor exactly therows affected (those where a real
contract_date_startexists anddisagrees with
date_version), mirroring the pattern this samefunction already uses for the other branch - employees who had no
prior contract at all, whose newly-created
hr.versionrow explicitlygets
date_versionset fromcreate_datea few lines below. Thisfix brings the table-rename branch up to the same standard.
Testing
Reproduced and verified against a real database migrated through
16.0 -> 17.0 -> 18.0 -> 19.0 (OpenUpgrade,
-u all). Before the fix:recomputing a genuine pre-migration payslip via
compute_sheet()wipes its lines to zero. Applied the equivalent
UPDATEmanuallyagainst the affected
hr_versionrows and confirmed the samepayslips then recompute with real salary-rule output again, and that
date_versionvalues post-fix match each employee's real originalcontract start date rather than the single migration-run date.