[19.0][MIG] partner_autocomplete: cleanup obsolete res.partner/res.company fields#5631
[19.0][MIG] partner_autocomplete: cleanup obsolete res.partner/res.company fields#5631dnplkndll wants to merge 1 commit into
Conversation
…fields The 18.0 partner_autocomplete module added three fields that no longer exist in 19.0: - res.company.partner_gid - res.partner.additional_info - res.partner.partner_gid Per upgrade_analysis.txt those are DEL. The script directory previously contained only upgrade_analysis.txt — no pre-migration.py and no upgrade_analysis_work.txt — so the migration relied on Odoo's standard upgrade flow to clean up the stale ir_model_fields rows and the matching inheritance views (view_partner_simple_form_inherit_partner_autocomplete, view_res_partner_form_inherit_partner_autocomplete, both also DEL in the analysis). That flow does not in fact prune them — the rows survive and trip cross-cutting view validation when later modules' data XML loads (reproduced on l10n_ae/data/account_tax_report_data.xml:3 with the error "Field 'partner_gid' does not exist in model 'res.partner'"). Add a pre-migration that deletes the stale field xml_ids + the orphan view xml_ids via openupgrade.delete_records_safely_by_xml_id, and a companion upgrade_analysis_work.txt that annotates the analysis blocks. Reproduced and verified on the same fresh 18.0 CE-all install used for the hr companion PR; with this patch and the hr/loyalty companions applied, the migration progresses past the previous crash point and continues into the next module's load.
4d338e0 to
a8e0975
Compare
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.
|
Please don't do this. We don't explicitly clean things, unless there's a conflict not doing so. Why? First, because one of the aims of OpenUpgrade is to preserve at maximum the previous information, as that can be used by other migration scripts for doing their work, or simply to recover from disasters. Secondly, there are other tools that do that cleanup if needed. In the case of the views, they are naturally removed on the next real update ( Please do the strict migration scripts. |
|
Closing per maintainer guidance in #5631 (comment). Understood: OpenUpgrade aims to preserve previous information, the natural For the specific failure mode that motivated these PRs (cross-cutting view validation triggered by Thanks for the clear philosophical guidance — saved me from writing another 100+ similar PRs. |
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.
What
Add
openupgrade_scripts/scripts/partner_autocomplete/19.0.1.1/:pre-migration.pywithcleanup_obsolete_partner_autocomplete_records(env)upgrade_analysis_work.txtannotating the analysis blocksThe pre-migration deletes the stale
ir_model_fieldsrows + orphaninheritance
ir_ui_viewrecords for three fields and two views the 18.0partner_autocompletemodule added that the 19.0 source no longerdefines (per
upgrade_analysis.txt):res.company.partner_gidres.partner.additional_infores.partner.partner_gidview_partner_simple_form_inherit_partner_autocompleteview_res_partner_form_inherit_partner_autocompleteWhy
The directory previously contained only the auto-generated
upgrade_analysis.txt. The migration relied on Odoo's standard upgradeflow to clean up DEL fields and DEL views. That holds for some module
upgrades but not all — in this case the stale
ir_model_fieldsrowsplus the matching views (whose
arch_dbretains<field name=\"partner_gid\"/>etc.) survive the upgrade. When anylater module's data XML load triggers cross-cutting view validation,
the orphan view tries to render and Odoo raises:
```
Field 'partner_gid' does not exist in model 'res.partner'
Field 'additional_info' does not exist in model 'res.partner'
```
which aborts the migration. Reproduced on a fresh 18.0 → 19.0 install
(
odoo -i allthen-u all): the crash hits at module 217/608l10n_aewhile parsingaccount_tax_report_data.xml:3.How
cleanup_obsolete_partner_autocomplete_records(env)lists the fiveknown-obsolete xml_ids and passes them to
openupgrade.delete_records_safely_by_xml_id. That deletes their_model_databackrefs + the underlyingir_model_fields/ir_ui_viewrecords together, falling back tonoupdate=Trueif arecord can't be removed (per the helper's existing behaviour).
The companion
upgrade_analysis_work.txtcarries the standardsection structure with one
# DONEblock above each DEL group, plus a# NOTHING TO DOfor the obsolete-model entries (the standardmodule-removal flow drops those tables) and the DEL access-rights /
cron entries (those are deleted by the standard upgrade).
Test plan
([19.0][FIX] loyalty: clear stale mail.template.lang referencing removed _get_mail_partner #5629) and the hr cleanup fix
([19.0][FIX] hr: cleanup obsolete hr.employee fields from merged hr_contract #5630) applied. Without this patch, migration
crashes at module 217/608 (
l10n_ae).past the partner_autocomplete-related crash. Continued failures
surface separately (e.g.
siretonres.partnerfroml10n_fr— that's a future PR).Related
This fix is one of a small series surfacing the same class of issue:
modules with DEL field/view entries in their 19.0 analysis whose
standard upgrade flow does not actually prune the stale records.