From 676db1f5c36abee92801e588e8836d7ee4466846 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Tue, 26 Oct 2021 17:06:13 +0200 Subject: [PATCH] [IMP] web_disable_export_group: Differenciate between the XLSX export and the standard export --- web_disable_export_group/README.rst | 13 +++---- web_disable_export_group/__manifest__.py | 2 +- .../migrations/14.0.1.1.0/post-migration.py | 16 ++++++++ web_disable_export_group/models/ir_http.py | 4 +- web_disable_export_group/readme/CONFIGURE.rst | 4 +- .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 6 +-- web_disable_export_group/readme/USAGE.rst | 2 +- web_disable_export_group/security/groups.xml | 6 ++- .../static/description/index.html | 15 ++++---- .../static/src/js/disable_export_group.js | 30 +++------------ .../src/js/web_disable_export_group_tour.js | 38 ++----------------- web_disable_export_group/tests/test_tour.py | 37 +++++++++--------- 13 files changed, 70 insertions(+), 104 deletions(-) create mode 100644 web_disable_export_group/migrations/14.0.1.1.0/post-migration.py diff --git a/web_disable_export_group/README.rst b/web_disable_export_group/README.rst index 6d41a552f..58ec4a2a2 100644 --- a/web_disable_export_group/README.rst +++ b/web_disable_export_group/README.rst @@ -25,11 +25,9 @@ Web Disable Export Group |badge1| |badge2| |badge3| |badge4| |badge5| -In the standard Odoo the UI option 'Export' that is present in the 'Action' menu -and the 'Export All' button of any list view is always enabled (for every user). +The standard export group prevents both options: 'Direct Export (xlsx)' and 'Export All'. -This module makes the option 'Export' and 'Export All' enabled only for the users -that belong to the Export Data group. +This module adds a new group for the 'Direct Export (xlsx)' feature, leaving the standard one for only the 'Export All' feature. Admin user can always use the export option. @@ -41,13 +39,13 @@ Admin user can always use the export option. Configuration ============= -Enable the group "Export Data group" to the users who are allowed to -make use of the option 'Export'. +Enable the group "Direct Export" to the users who are allowed to +make use of the option 'Export xlsx'. Usage ===== -Every user without *Export Data* permission won't have the option available. +Every user without *Direct Export (xlsx)* permission won't have the option available. Bug Tracker =========== @@ -81,6 +79,7 @@ Contributors * David Vidal * João Marques * Alexandre Díaz + * Víctor Martínez Maintainers ~~~~~~~~~~~ diff --git a/web_disable_export_group/__manifest__.py b/web_disable_export_group/__manifest__.py index 7a4be4db9..490893441 100644 --- a/web_disable_export_group/__manifest__.py +++ b/web_disable_export_group/__manifest__.py @@ -4,7 +4,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Web Disable Export Group", - "version": "14.0.1.0.0", + "version": "14.0.1.1.0", "license": "AGPL-3", "author": "Onestein, " "Tecnativa, " "Odoo Community Association (OCA)", "website": "https://github.com/OCA/web", diff --git a/web_disable_export_group/migrations/14.0.1.1.0/post-migration.py b/web_disable_export_group/migrations/14.0.1.1.0/post-migration.py new file mode 100644 index 000000000..52ff69fc6 --- /dev/null +++ b/web_disable_export_group/migrations/14.0.1.1.0/post-migration.py @@ -0,0 +1,16 @@ +from openupgradelib import openupgrade + + +def add_new_group_from_group(self, env, group, new_group): + groups = env["res.groups"].search([("implied_ids", "=", group.id)]) + groups.write({"implied_ids": [(4, new_group.id)]}) + group.users.write({"groups_id": [(4, new_group.id)]}) + + +@openupgrade.migrate() +def migrate(env, version): + group = env.ref("web_disable_export_group.group_export_data") + new_group = env.ref("web_disable_export_group.group_export_xlsx_data") + add_new_group_from_group(env, group, new_group) + group = env.ref("base.group_allow_export") + add_new_group_from_group(env, group, new_group) diff --git a/web_disable_export_group/models/ir_http.py b/web_disable_export_group/models/ir_http.py index 156f13160..562ff40d9 100644 --- a/web_disable_export_group/models/ir_http.py +++ b/web_disable_export_group/models/ir_http.py @@ -13,8 +13,8 @@ class Http(models.AbstractModel): user = request.env.user res.update( { - "group_export_data": user - and user.has_group("web_disable_export_group.group_export_data"), + "group_xlsx_export_data": user + and user.has_group("web_disable_export_group.group_export_xlsx_data"), } ) return res diff --git a/web_disable_export_group/readme/CONFIGURE.rst b/web_disable_export_group/readme/CONFIGURE.rst index df6b1e4b7..f32251f68 100644 --- a/web_disable_export_group/readme/CONFIGURE.rst +++ b/web_disable_export_group/readme/CONFIGURE.rst @@ -1,2 +1,2 @@ -Enable the group "Export Data group" to the users who are allowed to -make use of the option 'Export'. +Enable the group "Direct Export" to the users who are allowed to +make use of the option 'Export xlsx'. diff --git a/web_disable_export_group/readme/CONTRIBUTORS.rst b/web_disable_export_group/readme/CONTRIBUTORS.rst index d34bdc8b6..10aca8773 100644 --- a/web_disable_export_group/readme/CONTRIBUTORS.rst +++ b/web_disable_export_group/readme/CONTRIBUTORS.rst @@ -8,3 +8,4 @@ * David Vidal * João Marques * Alexandre Díaz + * Víctor Martínez diff --git a/web_disable_export_group/readme/DESCRIPTION.rst b/web_disable_export_group/readme/DESCRIPTION.rst index fc67346c3..cbe8c22ec 100644 --- a/web_disable_export_group/readme/DESCRIPTION.rst +++ b/web_disable_export_group/readme/DESCRIPTION.rst @@ -1,7 +1,5 @@ -In the standard Odoo the UI option 'Export' that is present in the 'Action' menu -and the 'Export All' button of any list view is always enabled (for every user). +The standard export group prevents both options: 'Direct Export (xlsx)' and 'Export All'. -This module makes the option 'Export' and 'Export All' enabled only for the users -that belong to the Export Data group. +This module adds a new group for the 'Direct Export (xlsx)' feature, leaving the standard one for only the 'Export All' feature. Admin user can always use the export option. diff --git a/web_disable_export_group/readme/USAGE.rst b/web_disable_export_group/readme/USAGE.rst index 9e1706a1b..58da01296 100644 --- a/web_disable_export_group/readme/USAGE.rst +++ b/web_disable_export_group/readme/USAGE.rst @@ -1 +1 @@ -Every user without *Export Data* permission won't have the option available. +Every user without *Direct Export (xlsx)* permission won't have the option available. diff --git a/web_disable_export_group/security/groups.xml b/web_disable_export_group/security/groups.xml index 548e4c051..3eb23a749 100644 --- a/web_disable_export_group/security/groups.xml +++ b/web_disable_export_group/security/groups.xml @@ -2,8 +2,10 @@ - - Export Data + + Direct Export (xlsx) + + - + Web Disable Export Group