Skip to content

[20.0][FIX] openupgrade_framework: adapt patches to v20 - #26

Closed
FerDeNetlab wants to merge 1 commit into
hbrunn:20.0-mig-openupgrade_frameworkfrom
FerDeNetlab:20.0-fix-openupgrade_framework
Closed

FerDeNetlab wants to merge 1 commit into
hbrunn:20.0-mig-openupgrade_frameworkfrom
FerDeNetlab:20.0-fix-openupgrade_framework

Conversation

@FerDeNetlab

@FerDeNetlab FerDeNetlab commented Oct 26, 2026 •

Copy link
Copy Markdown

Fixes for OCA#6046 found while running a full 19.0 → 20.0 migration (crm, sale_management, purchase, stock, account + l10n_mx, project, hr, mrp, point_of_sale; demo data, 131 modules):

  • Keep attachments of removed models. v20 added IrModel._unlink_related_attachments (odoo/addons/base/models/ir_model.py), an @api.ondelete(at_uninstall=False) that deletes all ir.attachment rows of the model (including attachment=True binary fields) and marks their files for GC. In v20 those methods are only skipped for modules in registry.uninstalling_modules, which is still empty when _process_end runs, so every obsolete ir.model unlinked there loses its attachments while _drop_table keeps the table. The patch replaces it with a logging no-op, in line with "never drop tables".
  • Validate views one by one. The ValidationError handler of _check_xml reads self.xml_id/self.model, but _validate_module_views and create() call it on multi-record recordsets → Expected singleton aborts the upgrade instead of logging a warning.
  • Catch follow-up errors of a swallowed _raise_view_error. As it doesn't raise anymore, validation goes on and fails with AttributeError/KeyError/NameError/ValueError (e.g. _check_field_paths, _validate_domain_identifiers), which nobody caught.
  • Use cr.savepoint() in unlink. str(uuid4) never called uuid4, so all savepoints shared one name and were never released; the cursor helper also restores the ORM state on rollback.
  • Respect country_ids when auto installing in update_list, like button_install does (otherwise e.g. account_peppol gets installed on databases without a Peppol country).

With these (and migration scripts for the modules above) the test database migrates with all 1692 views valid and accounting data identical to v19.

Assisted-by: Claude Opus 5.5 (drafted with AI assistance, reviewed by me)

- keep the attachments of removed models: v20 added
  IrModel._unlink_related_attachments, which deletes them (incl. binary
  field data) when obsolete models are unlinked in _process_end
- validate views one by one: the warning handler read xml_id/model on a
  multi-record recordset, raising 'Expected singleton'
- also catch the errors raised after a swallowed _raise_view_error
- use the cursor's savepoint helper in unlink (uuid4 was never called and
  savepoints were never released)
- respect country_ids when auto installing modules in update_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants