From 38e04c2a21f90e37c6d287e4b4199e74170ac360 Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Fri, 12 Jun 2026 12:16:31 +0200 Subject: [PATCH 1/2] [IMP] web_excel_export_dynamic_expand: support several group by filters Improve the feature to work with any number of Group By filters applied simultaneously. --- web_excel_export_dynamic_expand/README.rst | 20 ++++++---- .../__manifest__.py | 2 +- .../controllers/excel_export.py | 25 +++++++----- .../readme/CONTRIBUTORS.md | 1 + .../readme/DESCRIPTION.md | 13 +++++-- .../static/description/index.html | 38 ++++++++++--------- .../static/src/js/data_export.esm.js | 33 +++++++++++----- 7 files changed, 83 insertions(+), 49 deletions(-) diff --git a/web_excel_export_dynamic_expand/README.rst b/web_excel_export_dynamic_expand/README.rst index 91705a9b6a1d..2149112c7340 100644 --- a/web_excel_export_dynamic_expand/README.rst +++ b/web_excel_export_dynamic_expand/README.rst @@ -1,7 +1,3 @@ -.. image:: https://odoo-community.org/readme-banner-image - :target: https://odoo-community.org/get-involved?utm_source=readme - :alt: Odoo Community Association - =============================== Web Excel Export Dynamic Expand =============================== @@ -17,7 +13,7 @@ Web Excel Export Dynamic Expand .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github @@ -32,9 +28,16 @@ Web Excel Export Dynamic Expand |badge1| |badge2| |badge3| |badge4| |badge5| -When exporting a tree view to an Excel file, you can decide if you want -to export only the main groups or the full tree, depending if all groups -are collapsed, or there is one open. +When exporting a list view to an Excel file, the export mirrors the +current group expansion state. The number of group levels visible in the +UI determines how many levels are included in the export: + +- All groups collapsed → only top-level group summary rows. +- N levels of groups expanded → N levels of group summary rows, each + with its aggregated values but no further detail. +- All levels expanded → full export including individual records. + +This works with any number of Group By filters applied simultaneously. **Table of contents** @@ -63,6 +66,7 @@ Contributors ------------ - Arnau Cruz +- Lois Rilo Maintainers ----------- diff --git a/web_excel_export_dynamic_expand/__manifest__.py b/web_excel_export_dynamic_expand/__manifest__.py index c7829110e1cf..2e6964e8211b 100644 --- a/web_excel_export_dynamic_expand/__manifest__.py +++ b/web_excel_export_dynamic_expand/__manifest__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2024 - ForgeFlow S.L. +# Copyright 2024-26 ForgeFlow S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { diff --git a/web_excel_export_dynamic_expand/controllers/excel_export.py b/web_excel_export_dynamic_expand/controllers/excel_export.py index a5d96f866abb..8a27b27fe211 100644 --- a/web_excel_export_dynamic_expand/controllers/excel_export.py +++ b/web_excel_export_dynamic_expand/controllers/excel_export.py @@ -1,4 +1,4 @@ -# Copyright 2024 ForgeFlow S.L. +# Copyright 2024-26 ForgeFlow S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import json @@ -25,14 +25,19 @@ def context(self): def context(self, value): self._context = value + def _strip_beyond_depth(self, node, current_depth, max_depth): + if current_depth >= max_depth: + aggregated_values = node.aggregated_values + node.children = OrderedDict() + node.data = [] + node.aggregated_values = aggregated_values + else: + for child_node in node.children.values(): + self._strip_beyond_depth(child_node, current_depth + 1, max_depth) + def from_group_data(self, fields, columns_headers, groups): - collapse_groups = self.context.get("collapse_groups") - if collapse_groups: - for _child_key, child_node in groups.children.items(): - aggregated_values = child_node.aggregated_values - if child_node.children: - child_node.children = OrderedDict() - if child_node.data: - child_node.data = [] - child_node.aggregated_values = aggregated_values + expand_depth = self.context.get("expand_depth") + if expand_depth is not None: + for child_node in groups.children.values(): + self._strip_beyond_depth(child_node, 0, expand_depth) return super().from_group_data(fields, columns_headers, groups) diff --git a/web_excel_export_dynamic_expand/readme/CONTRIBUTORS.md b/web_excel_export_dynamic_expand/readme/CONTRIBUTORS.md index 05cf886890dd..3459defc2ae4 100644 --- a/web_excel_export_dynamic_expand/readme/CONTRIBUTORS.md +++ b/web_excel_export_dynamic_expand/readme/CONTRIBUTORS.md @@ -1 +1,2 @@ - Arnau Cruz \ +- Lois Rilo \ diff --git a/web_excel_export_dynamic_expand/readme/DESCRIPTION.md b/web_excel_export_dynamic_expand/readme/DESCRIPTION.md index a4c59ad43d70..6dc06c519ab3 100644 --- a/web_excel_export_dynamic_expand/readme/DESCRIPTION.md +++ b/web_excel_export_dynamic_expand/readme/DESCRIPTION.md @@ -1,3 +1,10 @@ -When exporting a tree view to an Excel file, you can decide if you want -to export only the main groups or the full tree, depending if all groups -are collapsed, or there is one open. +When exporting a list view to an Excel file, the export mirrors the +current group expansion state. The number of group levels visible in +the UI determines how many levels are included in the export: + +- All groups collapsed → only top-level group summary rows. +- N levels of groups expanded → N levels of group summary rows, each + with its aggregated values but no further detail. +- All levels expanded → full export including individual records. + +This works with any number of Group By filters applied simultaneously. diff --git a/web_excel_export_dynamic_expand/static/description/index.html b/web_excel_export_dynamic_expand/static/description/index.html index efbef42210e4..f8bff016d0fc 100644 --- a/web_excel_export_dynamic_expand/static/description/index.html +++ b/web_excel_export_dynamic_expand/static/description/index.html @@ -3,7 +3,7 @@ -README.rst +Web Excel Export Dynamic Expand -
+
+

Web Excel Export Dynamic Expand

- - -Odoo Community Association - -
-

Web Excel Export Dynamic Expand

-

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

-

When exporting a tree view to an Excel file, you can decide if you want -to export only the main groups or the full tree, depending if all groups -are collapsed, or there is one open.

+

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

+

When exporting a list view to an Excel file, the export mirrors the +current group expansion state. The number of group levels visible in the +UI determines how many levels are included in the export:

+
    +
  • All groups collapsed → only top-level group summary rows.
  • +
  • N levels of groups expanded → N levels of group summary rows, each +with its aggregated values but no further detail.
  • +
  • All levels expanded → full export including individual records.
  • +
+

This works with any number of Group By filters applied simultaneously.

Table of contents

    @@ -391,7 +393,7 @@

    Web Excel Export Dynamic Expand

-

Bug Tracker

+

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed @@ -399,21 +401,22 @@

Bug Tracker

Do not contact contributors directly about support or help with technical issues.

-
diff --git a/web_excel_export_dynamic_expand/static/src/js/data_export.esm.js b/web_excel_export_dynamic_expand/static/src/js/data_export.esm.js index 96158ab00cb2..29ac9c079ad4 100644 --- a/web_excel_export_dynamic_expand/static/src/js/data_export.esm.js +++ b/web_excel_export_dynamic_expand/static/src/js/data_export.esm.js @@ -3,15 +3,30 @@ import {ListController} from "@web/views/list/list_controller"; patch(ListController.prototype, { async downloadExport() { - const hasDataRow = document.querySelectorAll(".o_data_row").length > 0; - const hasGroup = document.querySelectorAll(".o_group_header").length > 0; - const collapseGroups = !hasDataRow && hasGroup; - - this.props.context = { - ...this.props.context, - collapse_groups: collapseGroups, - }; - + const root = this.model.root; + if (root.isGrouped && root.groups && root.groups.length > 0) { + const expandDepth = this._getExpandDepth(root); + this.props.context = { + ...this.props.context, + expand_depth: expandDepth, + }; + } await super.downloadExport(...arguments); }, + + _getExpandDepth(list, depth = 0) { + if (!list.isGrouped) { + return depth; + } + let maxDepth = depth; + for (const group of list.groups) { + if (!group.isFolded && group.list) { + const childDepth = this._getExpandDepth(group.list, depth + 1); + if (childDepth > maxDepth) { + maxDepth = childDepth; + } + } + } + return maxDepth; + }, }); From 042384b9d863ad8bebbfa59ae586e370c24b388f Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Wed, 4 Nov 2026 17:48:43 +0000 Subject: [PATCH 2/2] [BOT] post-merge updates --- README.md | 2 +- web_excel_export_dynamic_expand/README.rst | 8 +++++-- .../__manifest__.py | 2 +- .../static/description/index.html | 24 ++++++++++++------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index bd93abf7e487..169dee141fd6 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ addon | version | maintainers | summary [web_editor_class_selector](web_editor_class_selector/) | 18.0.1.0.0 | carlos-lopez-tecnativa | Web editor class selector [web_editor_disable_chatgpt](web_editor_disable_chatgpt/) | 18.0.1.0.0 | | Web Disable ChatGPT [web_environment_ribbon](web_environment_ribbon/) | 18.0.1.0.3 | | Web Environment Ribbon -[web_excel_export_dynamic_expand](web_excel_export_dynamic_expand/) | 18.0.1.0.0 | | Export collapsed groups or the full tree, based on its view. +[web_excel_export_dynamic_expand](web_excel_export_dynamic_expand/) | 18.0.1.1.0 | | Export collapsed groups or the full tree, based on its view. [web_favicon](web_favicon/) | 18.0.1.0.1 | | Allows to set a custom shortcut icon (aka favicon) [web_filter_header_button](web_filter_header_button/) | 18.0.1.0.0 | | Show selected filters as buttons in the control panel [web_font_size_report_layout](web_font_size_report_layout/) | 18.0.1.0.0 | | Adds a font size selector (pt) to the Document Layout wizard diff --git a/web_excel_export_dynamic_expand/README.rst b/web_excel_export_dynamic_expand/README.rst index 2149112c7340..5ed9d7e3719f 100644 --- a/web_excel_export_dynamic_expand/README.rst +++ b/web_excel_export_dynamic_expand/README.rst @@ -1,3 +1,7 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + =============================== Web Excel Export Dynamic Expand =============================== @@ -7,13 +11,13 @@ Web Excel Export Dynamic Expand !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:0ebaf3ae34e14b004119de667f5e9923e0e3cc6a0e57349fd4b860af03a2b9c2 + !! source digest: sha256:ced8400976e85e06231ac225317538ade452c1b9cc5a427ad22ae7591ec2e9d1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github diff --git a/web_excel_export_dynamic_expand/__manifest__.py b/web_excel_export_dynamic_expand/__manifest__.py index 2e6964e8211b..620278025337 100644 --- a/web_excel_export_dynamic_expand/__manifest__.py +++ b/web_excel_export_dynamic_expand/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Web Excel Export Dynamic Expand", "summary": "Export collapsed groups or the full tree, based on its view.", - "version": "18.0.1.0.0", + "version": "18.0.1.1.0", "author": "ForgeFlow, Odoo Community Association (OCA)", "website": "https://github.com/OCA/web", "license": "AGPL-3", diff --git a/web_excel_export_dynamic_expand/static/description/index.html b/web_excel_export_dynamic_expand/static/description/index.html index f8bff016d0fc..a1f58e2ba4b5 100644 --- a/web_excel_export_dynamic_expand/static/description/index.html +++ b/web_excel_export_dynamic_expand/static/description/index.html @@ -360,16 +360,21 @@ -
-

Web Excel Export Dynamic Expand

+
+ + +Odoo Community Association + +
+

Web Excel Export Dynamic Expand

-

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

When exporting a list view to an Excel file, the export mirrors the current group expansion state. The number of group levels visible in the UI determines how many levels are included in the export:

@@ -393,7 +398,7 @@

Web Excel Export Dynamic Expand

-

Bug Tracker

+

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed @@ -401,22 +406,22 @@

Bug Tracker

Do not contact contributors directly about support or help with technical issues.

+