From ef86540d4211a29472b372d0a60da5cc4e3c9e15 Mon Sep 17 00:00:00 2001 From: muhammadali124 Date: Tue, 20 Oct 2026 12:38:52 +0500 Subject: [PATCH] [FIX] hr: backfill date_version for migrated contracts 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). --- .../scripts/hr/19.0.1.1/post-migration.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openupgrade_scripts/scripts/hr/19.0.1.1/post-migration.py b/openupgrade_scripts/scripts/hr/19.0.1.1/post-migration.py index 94043f7889e7..9e843d5be37f 100644 --- a/openupgrade_scripts/scripts/hr/19.0.1.1/post-migration.py +++ b/openupgrade_scripts/scripts/hr/19.0.1.1/post-migration.py @@ -54,6 +54,15 @@ def fill_hr_version(env): f"ALTER TABLE hr_version ADD COLUMN IF NOT EXISTS {link_column} int", ) env.cr.execute(f"UPDATE hr_version SET {link_column}=id") + if openupgrade.column_exists(env.cr, "hr_version", "contract_date_start"): + env.cr.execute( + """ + UPDATE hr_version + SET date_version = contract_date_start + WHERE contract_date_start IS NOT NULL + AND date_version != contract_date_start + """ + ) env.cr.execute( f""" UPDATE hr_version