Skip to content

[ADD] xml-deprecated-css-class#189

Open
bosd wants to merge 1 commit into
OCA:mainfrom
bosd:add-xml-deprecated-css-class
Open

[ADD] xml-deprecated-css-class#189
bosd wants to merge 1 commit into
OCA:mainfrom
bosd:add-xml-deprecated-css-class

Conversation

@bosd
Copy link
Copy Markdown

@bosd bosd commented May 14, 2026

Summary

Adds a new check, xml-deprecated-css-class, that detects legacy CSS classes in XML / QWeb view files and suggests the modern replacement. Each hit emits a single warning with the exact line number and the recommended substitution.

Why

Real-world OCA repositories still carry a long tail of Bootstrap 3 utility classes that Odoo silently broke when bundling Bootstrap 5 (since version 15.0), plus a handful of Odoo legacy oe_* classes that have direct BS5 replacements. A representative audit across one private deployment and a sample of OCA repos shows:

Class Total hits
btn-default 114
panel / panel-* (combined) 23
oe_grey 23
oe_right 22
pull-right 14
pull-left 2

(oe_inline (829), oe_button_box (258), oe_edit_only (246) are also widespread but not flagged here because their replacements depend on context — they need their own checks with structural logic.)

What's covered

Only unambiguous one-to-one mappings, so the rule can be enabled without manual review of every hit:

  • Bootstrap 3 → 5 utility renames:
    pull-left → float-start, pull-right → float-end,
    panel → card, panel-default → card, panel-heading → card-header,
    panel-body → card-body, panel-title → card-title, panel-footer → card-footer,
    img-responsive → img-fluid, btn-default → btn-secondary.
  • Odoo legacy → BS5 utility:
    oe_left → float-start, oe_right → float-end, oe_grey → text-muted.

Each entry lives in a single deprecated_css_classes dict on ChecksOdooModuleXML, so adding more mappings later is a one-line change.

Version gating

The check fires only when self.module_version >= 15.0, mirroring xml-deprecated-oe-chatter's gating pattern. Modules targeting older Odoo versions are left alone — Bootstrap 3 is still legitimate there.

Tests

  • New fixture test_repo/odoo18_module/views/deprecated_css_class.xml exercising all 13 mapping entries (12 hits — panel-default co-occurs with panel on the same line, so two warnings on one element).
  • EXPECTED_ERRORS updated: "xml-deprecated-css-class": 12.
  • Verified locally via the CLI on the fixture — every hit lands on the right line, with the right replacement string.

Not in scope

  • Ambiguous-replacement classes (oe_inline, oe_button_box, oe_edit_only, hidden-xs/sm/md/lg, well, glyphicon-*). Each of these wants its own context-aware check; that's better as a follow-up than padding this PR with rules that need manual review.
  • Auto-fix. The hook reports; the developer fixes. (Auto-fix could land later under cli_fixit.py.)

New check detecting legacy CSS classes in XML / QWeb views, with a
suggested modern replacement. Two sources are covered:

* Bootstrap 3 utility classes that were renamed in Bootstrap 5
  (Odoo bundles Bootstrap 5 since version 15.0):
  ``pull-left/right``, ``panel*``, ``img-responsive``, ``btn-default``.
* Odoo legacy classes superseded by Bootstrap 5 utilities:
  ``oe_left``, ``oe_right``, ``oe_grey``.

Only unambiguous one-to-one mappings are flagged. Ambiguous classes
(``oe_inline``, ``oe_button_box``, ``oe_edit_only`` etc.) are left out
so the rule can be enabled without manual review of every hit.

The check is version-gated to Odoo 15.0+ via ``self.module_version``,
mirroring the gating pattern used by ``xml-deprecated-oe-chatter``.
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.

1 participant