From 95c87cd5394934c4e2be893acc6249c5b2c39615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20D=2E=20D=C3=ADaz?= Date: Wed, 7 Jul 2021 19:30:52 +0200 Subject: [PATCH] [IMP] web_disable_export_group: Disable 'export all' button --- web_disable_export_group/README.rst | 7 ++-- .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 6 ++-- .../static/description/index.html | 7 ++-- .../static/src/js/disable_export_group.js | 33 ++++++++++++++++--- .../src/js/web_disable_export_group_tour.js | 8 +++++ 6 files changed, 48 insertions(+), 14 deletions(-) diff --git a/web_disable_export_group/README.rst b/web_disable_export_group/README.rst index bbd1fe6ae..c1afee4fc 100644 --- a/web_disable_export_group/README.rst +++ b/web_disable_export_group/README.rst @@ -26,10 +26,10 @@ Web Disable Export Group |badge1| |badge2| |badge3| |badge4| |badge5| In the standard Odoo the UI option 'Export' that is present in the 'Action' menu -of any list view is always enabled (for every user). +and the 'Export All' button of any list view is always enabled (for every user). -This module makes the option 'Export' enabled only for the users that belong -to the Export Data group. +This module makes the option 'Export' and 'Export All' enabled only for the users +that belong to the Export Data group. Admin user can always use the export option. @@ -80,6 +80,7 @@ Contributors * David Vidal * João Marques + * Alexandre Díaz Maintainers ~~~~~~~~~~~ diff --git a/web_disable_export_group/readme/CONTRIBUTORS.rst b/web_disable_export_group/readme/CONTRIBUTORS.rst index 043f98583..d34bdc8b6 100644 --- a/web_disable_export_group/readme/CONTRIBUTORS.rst +++ b/web_disable_export_group/readme/CONTRIBUTORS.rst @@ -7,3 +7,4 @@ * David Vidal * João Marques + * Alexandre Díaz diff --git a/web_disable_export_group/readme/DESCRIPTION.rst b/web_disable_export_group/readme/DESCRIPTION.rst index ecc454e24..fc67346c3 100644 --- a/web_disable_export_group/readme/DESCRIPTION.rst +++ b/web_disable_export_group/readme/DESCRIPTION.rst @@ -1,7 +1,7 @@ In the standard Odoo the UI option 'Export' that is present in the 'Action' menu -of any list view is always enabled (for every user). +and the 'Export All' button of any list view is always enabled (for every user). -This module makes the option 'Export' enabled only for the users that belong -to the Export Data group. +This module makes the option 'Export' and 'Export All' enabled only for the users +that belong to the Export Data group. Admin user can always use the export option. diff --git a/web_disable_export_group/static/description/index.html b/web_disable_export_group/static/description/index.html index c9b146cb4..7fe27df04 100644 --- a/web_disable_export_group/static/description/index.html +++ b/web_disable_export_group/static/description/index.html @@ -369,9 +369,9 @@ ul.auto-toc { !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

In the standard Odoo the UI option ‘Export’ that is present in the ‘Action’ menu -of any list view is always enabled (for every user).

-

This module makes the option ‘Export’ enabled only for the users that belong -to the Export Data group.

+and the ‘Export All’ button of any list view is always enabled (for every user).

+

This module makes the option ‘Export’ and ‘Export All’ enabled only for the users +that belong to the Export Data group.

Admin user can always use the export option.

Table of contents

@@ -424,6 +424,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
  • Tecnativa:
    • David Vidal
    • João Marques
    • +
    • Alexandre Díaz
  • diff --git a/web_disable_export_group/static/src/js/disable_export_group.js b/web_disable_export_group/static/src/js/disable_export_group.js index 5411aae33..cedba0525 100644 --- a/web_disable_export_group/static/src/js/disable_export_group.js +++ b/web_disable_export_group/static/src/js/disable_export_group.js @@ -1,17 +1,22 @@ /* Copyright 2016 Onestein Copyright 2018 Tecnativa - David Vidal + Copyright 2021 Tecnativa - Alexandre Díaz License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ odoo.define("web_disable_export_group", function(require) { "use strict"; - var core = require("web.core"); - var Sidebar = require("web.Sidebar"); - var session = require("web.session"); - var _t = core._t; + const core = require("web.core"); + const Sidebar = require("web.Sidebar"); + const session = require("web.session"); + const AbstractController = require("web.AbstractController"); + const _t = core._t; Sidebar.include({ + /** + * @override + */ _addItems: function(sectionCode, items) { - var _items = items; + let _items = items; if ( !session.is_superuser && sectionCode === "other" && @@ -23,4 +28,22 @@ odoo.define("web_disable_export_group", function(require) { this._super(sectionCode, _items); }, }); + + AbstractController.include({ + /** + * @override + */ + is_action_enabled: function(action) { + if ( + !session.is_superuser && + action && + action.startsWith("export_") && + !session.group_export_data + ) { + return false; + } + + return this._super.apply(this, arguments); + }, + }); }); diff --git a/web_disable_export_group/static/src/js/web_disable_export_group_tour.js b/web_disable_export_group/static/src/js/web_disable_export_group_tour.js index 00c1c4e8e..f1e51de0b 100644 --- a/web_disable_export_group/static/src/js/web_disable_export_group_tour.js +++ b/web_disable_export_group/static/src/js/web_disable_export_group_tour.js @@ -17,6 +17,10 @@ odoo.define("web_disable_export_group.tour", function(require) { "/web#model=ir.ui.view&view_type=list&cids=&action=base.action_ui_view", }, [ + { + content: "Check if 'Export all' button exists", + trigger: ".o_list_buttons:has(.o_list_export_xlsx)", + }, { content: "Select all records", trigger: ".custom-control-input:first", @@ -42,6 +46,10 @@ odoo.define("web_disable_export_group.tour", function(require) { "/web#model=ir.ui.view&view_type=list&cids=&action=base.action_ui_view", }, [ + { + content: "Check if 'Export all' button exists", + trigger: ".o_list_buttons:not(:has(.o_list_export_xlsx))", + }, { content: "Select all records", trigger: ".custom-control-input:first",