[IMP] openupgrade: strip_view_arch_attrs() helper for RNG-removed attrs#2
Draft
dnplkndll wants to merge 4 commits into
Draft
[IMP] openupgrade: strip_view_arch_attrs() helper for RNG-removed attrs#2dnplkndll wants to merge 4 commits into
dnplkndll wants to merge 4 commits into
Conversation
…ng_card UPDATE
The card_campaign cross-reference UPDATE inside merge_models() (active when
marketing_card is installed) had two bugs:
1. Used `{old_model}` / `{new_model}` as sql.SQL().format() placeholders but
passed them via the psycopg2 params dict — raising
`KeyError: 'old_model'` from psycopg2/sql.py at runtime.
2. Double `AND` in WHERE clause:
`AND mt.{ref_field} = c.res_id AND AND c.campaign_id = cc.id`
Both fixed: switch to `%(old_model)s` / `%(new_model)s` (matching the params
dict) and remove the redundant AND.
Triggered in practice by any model-merge migration when marketing_card is
installed (e.g., OCA/OpenUpgrade hr_recruitment hr.candidate -> hr.applicant
merge on 18.0 -> 19.0).
[FIX] merge_models: psycopg2 param style + double-AND typo (marketing_card UPDATE)
Common shape across major Odoo migrations: a RelaxNG schema tightens between versions, attributes valid in N become invalid in N+1, and stored arch_db blobs that still carry them fail view validation when the module is upgraded — leaving the view unrenderable and breaking downstream xml_id lookups. This helper does the SQL-side pre-migration scrub: scoped by view type, takes a list of (element_regex, attr_regex) patterns, and rewrites arch_db with the matches stripped. Multi-lang jsonb arch_db (17.0+) handled via jsonb_each + jsonb_object_agg. First consumer: openupgrade_scripts/scripts/base/19.0.1.3 strips <group expand=...>, <field expand=...>, and <group string="Group By"> from <search> views, which the 19.0 RNG schema rejects.
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.
Common shape across major Odoo migrations: a RelaxNG schema tightens between versions, attributes valid in N become invalid in N+1, and stored
arch_dbblobs that still carry them fail view validation when the module is upgraded — leaving the view unrenderable and breaking downstreamxml_idlookups.This helper does the SQL-side pre-migration scrub, scoped by view type, with
(element_regex, attr_regex)pattern pairs. Multi-lang jsonb arch_db (17.0+) handled viajsonb_each+jsonb_object_agg.Signature
view_type:'search','form', etc. Strict type-scoping is intentional — RNG removals are type-specific. e.g.<list expand=...>remained valid in 19.0 even though<group expand=...>was removed; broader stripping would brick the list views.attr_patterns: iterable of(element_regex, attr_regex)POSIX regex pairs. Strips<{element_regex}[^>]*?\s+{attr_regex}occurrences, preserving the rest of the element tag.like_hints: optional substring filter to skip views that clearly carry none of the patterns (cheap pre-filter).First consumer
OpenUpgrade
base/19.0.1.3/pre-migration.pystrips<group expand=...>,<field expand=...>(searchpanel), and<group string="Group By">from<search>views, which the 19.0 RNG schema rejects:Validated on a Tier-1 600-module Odoo seed: 181 affected views → 0 post-migration, sub-second wall-clock.
Notes
arch_dbis text not jsonb; helper raises rather than silently using the wrong code path.regexp_replace; not combined into a single alternation for clarity.\1preserves any other attrs on the same element tag.