Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
1
web_excel_export_dynamic_expand/controllers/__init__.py
Executable file
1
web_excel_export_dynamic_expand/controllers/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from . import excel_export
|
||||
38
web_excel_export_dynamic_expand/controllers/excel_export.py
Executable file
38
web_excel_export_dynamic_expand/controllers/excel_export.py
Executable file
@@ -0,0 +1,38 @@
|
||||
# Copyright 2024 ForgeFlow S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import json
|
||||
from collections import OrderedDict
|
||||
|
||||
from odoo import http
|
||||
|
||||
from odoo.addons.web.controllers.export import ExcelExport
|
||||
|
||||
|
||||
class CustomGroupsTreeNode(ExcelExport):
|
||||
@http.route("/web/export/xlsx", type="http", auth="user")
|
||||
def web_export_xlsx(self, data):
|
||||
params = json.loads(data)
|
||||
self.context = params.get("context", {})
|
||||
response = super().web_export_xlsx(data)
|
||||
return response
|
||||
|
||||
@property
|
||||
def context(self):
|
||||
return self._context
|
||||
|
||||
@context.setter
|
||||
def context(self, value):
|
||||
self._context = value
|
||||
|
||||
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
|
||||
return super().from_group_data(fields, columns_headers, groups)
|
||||
Reference in New Issue
Block a user