Skip to content

Conversation

MD-Jafor-Sadek-Khan
Copy link

Purpose

Add a compact, toggleable group-by button to list/tree view column headers so users can quickly group by a single field from the header.

Technical summary

  • Patch web.views.list.ListRenderer to add:
    • isColumnGroupable(column) — checks field metadata and excludes one2many, many2many, and non-stored computed fields.
    • isColumnCurrentlyGrouped(column) — detects if the list is currently grouped by column.name (single-level grouping).
    • getButtonStyle(column) — returns inline style string for the header button.
    • onGroupByColumn(ev) — toggles grouping by the clicked field, triggers model.load({ groupBy }), and updates header button UI (icons, colors, brief scale animation, hover styles).
  • UI insertion uses a small QWeb template that renders a button next to column labels in list headers.
  • Updates the visible state of all header buttons after model reload using a short delayed DOM update.

Files touched

  • static/src/js/list_header_cell.js — JS patch to ListRenderer.
  • static/src/xml/list_header_cell.xml — QWeb template injecting the header button.
  • __manifest__.py — module metadata and assets bundle registration.

Checklist

  • No debug console.log/console.warn in committed code.
  • Tests added / updated (none included in this PR).
  • Manual test steps included below.
  • Signed the OCA contribution form (CLA).

Manual testing steps

  1. Install the module.
  2. Open any list/tree view that contains a stored, non-relational field (e.g., a text, selection, or Many2one column).
  3. Verify a small toggle button appears to the right of the column label for groupable columns.
  4. Click the button:
    • If the list is not grouped by that field, the view reloads grouped by the field.
    • If the list is already grouped by that field, grouping is cleared.
  5. Confirm that relational columns (one2many, many2many) and known non-stored computed fields do not show the button.

Notes for reviewers

  • This patch intentionally supports only single-level grouping from the header (toggles between [] and [field]).
  • Styling and icons use standard Font Awesome classes available in Odoo backend themes. If your environment uses custom icon sets, icons may differ.
  • If you want automated coverage, I can add a minimal JS integration test that asserts model.root.groupBy changes after a simulated click.

Limitations / design decisions

  • Conservative metadata checks: if field metadata is missing or incomplete, the button will not be rendered to avoid unsafe grouping.
  • The UI update after model.load is performed via a short setTimeout to synchronize with the renderer lifecycle; if maintainers prefer, this can be refactored to a more robust event-hook approach.

Related issues / PRs

  • (none)

Add toggleable group-by button into List view so users can group by
a column directly from the list header. Keeps compatibility with existing
ListRenderer behaviour and avoids grouping by relational / non-stored fields.

- Validate field type and storeable property before grouping
- Update UI state (icons, styles) after model reload
- Remove debug output before merge

Co-authored-by: MD Jafor Sadek Khan [email protected]
Add toggleable group-by button into List view so users can group by
a column directly from the list header. Keeps compatibility with existing
ListRenderer behaviour and avoids grouping by relational / non-stored fields.

- Validate field type and storeable property before grouping
- Update UI state (icons, styles) after model reload
- Remove debug output before merge

Co-authored-by: MD Jafor Sadek Khan [email protected]
Add toggleable group-by button into List view so users can group by
a column directly from the list header. Keeps compatibility with existing
ListRenderer behaviour and avoids grouping by relational / non-stored fields.

- Validate field type and storeable property before grouping
- Update UI state (icons, styles) after model reload
- Remove debug output before merge

Co-authored-by: MD Jafor Sadek Khan [email protected]
Add toggleable group-by button into List view so users can group by
a column directly from the list header. Keeps compatibility with existing
ListRenderer behaviour and avoids grouping by relational / non-stored fields.

- Validate field type and storeable property before grouping
- Update UI state (icons, styles) after model reload
- Remove debug output before merge

Co-authored-by: MD Jafor Sadek Khan [email protected]
Add toggleable group-by button into List view so users can group by
a column directly from the list header. Keeps compatibility with existing
ListRenderer behaviour and avoids grouping by relational / non-stored fields.

- Validate field type and storeable property before grouping
- Update UI state (icons, styles) after model reload
- Remove debug output before merge

Co-authored-by: MD Jafor Sadek Khan [email protected]
Add toggleable group-by button into List view so users can group by
a column directly from the list header. Keeps compatibility with existing
ListRenderer behaviour and avoids grouping by relational / non-stored fields.

- Validate field type and storeable property before grouping
- Update UI state (icons, styles) after model reload
- Remove debug output before merge

Co-authored-by: MD Jafor Sadek Khan [email protected]
@legalsylvain
Copy link
Contributor

Hi @MD-Jafor-Sadek-Khan. Thanks for sharing.

  • could you follow OCA rules, regarding readme fragment files ?
  • I tested on runboat, and nothing appears. Could provide a printscreen. I'm not sure to understand.

regards.

…nality

- Ensured README fragment files (, , etc.) are present and correctly formatted.
- Verified module on Runboat; group-by toggle button now appears as expected.
- Added screenshot reference for reviewers.
…nality

- Ensured README fragment files (, , etc.) are present and correctly formatted.
- Verified module on Runboat; group-by toggle button now appears as expected.
- Added screenshot reference for reviewers.
@MD-Jafor-Sadek-Khan
Copy link
Author

MD-Jafor-Sadek-Khan commented Sep 21, 2025

Hi @legalsylvain ,

Thanks for your feedback. I’ve verified the module according to OCA guidelines regarding README fragment files. The readme fragments are included under the readme/ folder and are automatically processed to generate the main README.rst and documentation.

I’ve also tested the module on Runboat, and the group-by toggle button appears correctly in list views (e.g., Contacts, Sales, Inventory) for groupable columns. Please see the attached screenshot for reference. Note that in a small number of list views (e.g., Invoice, Bills, Credit Notes, Refunds), the button may not appear due to templates being replaced in the Odoo community code.

Let me know if any additional adjustments are needed.

Regards,
MD Jafor Sadek Khan

Screenshot from 2025-09-21 12-33-12 Screenshot from 2025-09-21 12-43-44

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