Repository navigation
[FIX] hr: backfill date_version for migrated contracts - #6064
Merged
pedrobaeza merged 1 commit intoOct 27, 2026
Merged
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
Contributor
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
Contributor
Author
|
@pedrobaeza Just checking in, anything else needed from my side here? Happy to make further changes if useful. |
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.versionrows whosedate_versioncolumn never existed on the old table. When the new,required=Truecolumn gets added by the ORM schema sync, it is left at its Python-declared default (fields.Date.today) for every converted 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 every migrated 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(), then silently 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 the migration (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 entirehr_versiontable (3,932 of 3,934 rows) ended up withdate_versionpinned to the single date the migration ran, and all ~3,100 pre-migration payslips (draft, verify, and done combined) are affected.Fix
Backfill
date_versionfromcontract_date_startfor exactly the rows affected (those where a realcontract_date_startexists and disagrees withdate_version), mirroring the pattern this same function already uses for the other branch - employees who had no prior contract at all, whose newly-createdhr.versionrow explicitly getsdate_versionset fromcreate_datea few lines below. This fix 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 viacompute_sheet()wipes its lines to zero. Applied the equivalentUPDATEmanually against the affectedhr_versionrows and confirmed the same payslips then recompute with real salary-rule output again, and thatdate_versionvalues post-fix match each employee's real original contract start date rather than the single migration-run date.