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 91705a9b6a1d..5ed9d7e3719f 100644 --- a/web_excel_export_dynamic_expand/README.rst +++ b/web_excel_export_dynamic_expand/README.rst @@ -11,7 +11,7 @@ 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 @@ -32,9 +32,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 +70,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..620278025337 100644 --- a/web_excel_export_dynamic_expand/__manifest__.py +++ b/web_excel_export_dynamic_expand/__manifest__.py @@ -1,10 +1,10 @@ -# Copyright (C) 2024 - ForgeFlow S.L. +# Copyright 2024-26 ForgeFlow S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "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/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..a1f58e2ba4b5 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