[ADD] xml-deprecated-css-class#189
Open
bosd wants to merge 1 commit into
Open
Conversation
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``.
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.
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:btn-defaultpanel/panel-*(combined)oe_greyoe_rightpull-rightpull-left(
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:
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.oe_left → float-start,oe_right → float-end,oe_grey → text-muted.Each entry lives in a single
deprecated_css_classesdict onChecksOdooModuleXML, so adding more mappings later is a one-line change.Version gating
The check fires only when
self.module_version >= 15.0, mirroringxml-deprecated-oe-chatter's gating pattern. Modules targeting older Odoo versions are left alone — Bootstrap 3 is still legitimate there.Tests
test_repo/odoo18_module/views/deprecated_css_class.xmlexercising all 13 mapping entries (12 hits —panel-defaultco-occurs withpanelon the same line, so two warnings on one element).EXPECTED_ERRORSupdated:"xml-deprecated-css-class": 12.Not in scope
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.cli_fixit.py.)