[19.0][FIX] hr: cleanup obsolete hr.employee fields from merged hr_contract#5630
Closed
dnplkndll wants to merge 1 commit into
Closed
[19.0][FIX] hr: cleanup obsolete hr.employee fields from merged hr_contract#5630dnplkndll wants to merge 1 commit into
dnplkndll wants to merge 1 commit into
Conversation
3 tasks
52943ad to
870d07a
Compare
3 tasks
dnplkndll
added a commit
to ledoent/OpenUpgrade
that referenced
this pull request
May 15, 2026
Add the merges introduced by today's PR series so the auto-built image includes them and the lab can `OPENUPGRADE_PULL_POLICY=always` again: - 19.0-fix-hr-null-write-date (OCA#5628) - 19.0-fix-loyalty-stale-mail-template-fields (OCA#5629) - 19.0-fix-hr-obsolete-fields-cleanup (OCA#5630) - 19.0-fix-partner-autocomplete-cleanup (OCA#5631) - 19.0-fix-l10n-fr-cleanup (OCA#5632) The companion lab repos.yaml is updated separately so local `make sync-repos` matches.
… views After the hr_contract → hr apriori merge, two classes of stale records linger and trip cross-cutting view validation later in the migration: 1. ir_model_fields rows + orphan ir_ui_view records for fields the 18.0 hr_contract module added to hr.employee that no longer exist in 19.0: contract_id, contract_ids, contract_warning, first_contract_date, vehicle (listed DEL in upgrade_analysis_work.txt as "# NOTHING TO DO"), plus contract_template_id, contract_type_id, contract_wage, contracts_count, is_in_contract (not flagged by the analyzer but verified stale via grep against all 19.0 hr* modules). 2. ir_ui_view records whose xml_ids were auto-renamed by openupgradelib (`<orig_name>_openupgrade_<id>`) during the merge to avoid xml_id collision. Two such views exist after the merge: res_config_settings_view_form_openupgrade_65293 and hr_departure_wizard_view_form_openupgrade_65294. Their arch_db still references 18.0-only xpath targets (e.g. //block[@name='employee_rights_setting_container']) and parents that 19.0 doesn't ship. Both classes manifest as a migration crash when l10n_ae's account_tax_report_data.xml triggers global view validation around module 217/608 — without this patch the migration fails with either "Field 'first_contract_date' does not exist in model 'hr.employee'" or "Element '<xpath expr=...>' cannot be located in parent view". Add two helpers in pre-migration: - cleanup_obsolete_hr_employee_fields(env) - cleanup_openupgrade_renamed_hr_views(env) Update upgrade_analysis_work.txt: the "# NOTHING TO DO" block for the DEL fields becomes "# DONE: stale ir_model_fields rows + orphan ir_ui_view records cleaned up in pre-migration".
870d07a to
50fae9e
Compare
dnplkndll
added a commit
to ledoent/OpenUpgrade
that referenced
this pull request
May 15, 2026
2 tasks
dnplkndll
added a commit
to ledoent/OpenUpgrade
that referenced
this pull request
May 16, 2026
Add the merges introduced by today's PR series so the auto-built image includes them and the lab can `OPENUPGRADE_PULL_POLICY=always` again: - 19.0-fix-hr-null-write-date (OCA#5628) - 19.0-fix-loyalty-stale-mail-template-fields (OCA#5629) - 19.0-fix-hr-obsolete-fields-cleanup (OCA#5630) - 19.0-fix-partner-autocomplete-cleanup (OCA#5631) - 19.0-fix-l10n-fr-cleanup (OCA#5632) The companion lab repos.yaml is updated separately so local `make sync-repos` matches.
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.
What
Add
cleanup_obsolete_hr_employee_fields(env)toopenupgrade_scripts/scripts/hr/19.0.1.1/pre-migration.pyand update thecompanion annotation in
upgrade_analysis_work.txt.The helper deletes the stale
ir_model_fieldsrows +ir_model_databackrefs + orphan
ir_ui_viewrecords onhr.employee/hr.employee.publicfor fields the 18.0hr_contractmodule addedthat no longer exist anywhere in 19.0:
contract_id,contract_ids,contract_warning,first_contract_date,vehiclehr* modules:
contract_template_id,contract_type_id,contract_wage,contracts_count,is_in_contractWhy
The relevant block in
upgrade_analysis_work.txt(lines 255-259 of thefile before this PR) was annotated
# NOTHING TO DOon the assumptionthat Odoo's standard registry rebuild would prune fields that disappear
from the source. That holds for normal module upgrades, but not when the
donor module is merged into another via
apriori— the field rows arere-parented to the receiving module (
hr) byupdate_module_namesand survive.
The stale rows themselves are inert, but the matching
ir_ui_viewrecords on
hr.employeeretain<field name=\"contract_id\"/>etc.in their
arch_db. When any later module's data XML load triggerscross-cutting view validation, those view-field lookups raise
Field 'first_contract_date' does not exist in model 'hr.employee'andabort the migration. Reproduced on a fresh 18.0 → 19.0 install
(
odoo -i allon the CE addons path, then-u all) — the migrationcrashes at module 217/608 (
l10n_ae) on parsingaddons/l10n_ae/data/account_tax_report_data.xml:3.How
Pre-migration runs two SQL passes:
ir_ui_viewrecords onhr.employee/hr.employee.publicwhosearch_dbmatches a regex over thestandard
<field name=\"X\"/>pattern for any of the ten obsoletenames. The 19.0 hr XML re-creates proper views during the same data
load via
mode=update.openupgrade.delete_records_safely_by_xml_idfor both
hr.field_hr_employee__*andhr.field_hr_employee_public__*.The annotation in
upgrade_analysis_work.txtis updated from# NOTHING TO DOto a# DONEcomment that explains why the"nothing to do" assumption was wrong and that five extra fields are
also covered.
Test plan
odoo -i allwith
--addons-pathscoped to the CE image's built-in addons,then
-u all). Without this patch, migration crashes at module217/608 on the error above.
hrmodule's pre-migration + post-migrationcomplete cleanly (
Module hr loaded in 5.00s, 5822 queries), themigration progresses past the previous crash point. A different
stale-field finding then surfaces on
res.partner(filedseparately).
Companion PRs
The loyalty fix is a prerequisite to reach the crash this PR addresses
during a clean migration. The hr null-write-date fix is independent.