From 89f6641f7fface1ca9a36c3e7bd6c15ae58d8bf4 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Fri, 3 Apr 2026 16:05:18 +0200 Subject: [PATCH] [IMP] Allow manager to export current view in excel We do not give export group access to avoid them to access all fields, those they do not have in view included --- project_customer_access/__manifest__.py | 5 +++++ project_customer_access/models/project.py | 8 ++++++++ .../static/src/js/export_all_patch.esm.js | 16 ++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 project_customer_access/static/src/js/export_all_patch.esm.js diff --git a/project_customer_access/__manifest__.py b/project_customer_access/__manifest__.py index b146958..bec951c 100644 --- a/project_customer_access/__manifest__.py +++ b/project_customer_access/__manifest__.py @@ -19,6 +19,11 @@ # https://github.com/OCA/server-auth "cross_connect_server", ], + "assets": { + "web.assets_backend": [ + "project_customer_access/static/src/js/export_all_patch.esm.js", + ], + }, "data": [ "data/res_groups.xml", "security/ir.model.access.csv", diff --git a/project_customer_access/models/project.py b/project_customer_access/models/project.py index 9885520..40e2df3 100644 --- a/project_customer_access/models/project.py +++ b/project_customer_access/models/project.py @@ -171,3 +171,11 @@ def write(self, values): self.env = self.sudo().env return super().write(values) + + def export_data(self, fields_to_export): + # Allow manager to export the list view to excel + # TODO we couuld add a check on the fields_to_export list to check there are + # no critical field + if self.env.user.has_group("project_customer_access.group_manager"): + return super(ProjectTask, self.sudo()).export_data(fields_to_export) + return super().export_data(fields_to_export) diff --git a/project_customer_access/static/src/js/export_all_patch.esm.js b/project_customer_access/static/src/js/export_all_patch.esm.js new file mode 100644 index 0000000..c6225a8 --- /dev/null +++ b/project_customer_access/static/src/js/export_all_patch.esm.js @@ -0,0 +1,16 @@ +import {registry} from "@web/core/registry"; +import {user} from "@web/core/user"; + +const cogMenuRegistry = registry.category("cogMenu"); + +const exportAllItem = cogMenuRegistry.get("export-all-menu"); + +const originalIsDisplayed = exportAllItem.isDisplayed; + +exportAllItem.isDisplayed = async (env) => { + const baseCondition = await originalIsDisplayed(env); + const hasMyCustomGroup = await user.hasGroup( + "project_customer_access.group_manager" + ); + return baseCondition || hasMyCustomGroup; +};