diff --git a/web_disable_export_group/README.rst b/web_disable_export_group/README.rst index 47dab701f..2676824f6 100644 --- a/web_disable_export_group/README.rst +++ b/web_disable_export_group/README.rst @@ -90,6 +90,8 @@ Contributors - Víctor Martínez - David Vidal +- SodexisTeam dev@sodexis.com + Maintainers ----------- diff --git a/web_disable_export_group/models/__init__.py b/web_disable_export_group/models/__init__.py index ea997b3c5..0650744f6 100644 --- a/web_disable_export_group/models/__init__.py +++ b/web_disable_export_group/models/__init__.py @@ -1,2 +1 @@ -from . import ir_http from . import models diff --git a/web_disable_export_group/models/ir_http.py b/web_disable_export_group/models/ir_http.py deleted file mode 100644 index 562ff40d9..000000000 --- a/web_disable_export_group/models/ir_http.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2018 Tecnativa - David Vidal -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo import models -from odoo.http import request - - -class Http(models.AbstractModel): - _inherit = "ir.http" - - def session_info(self): - res = super().session_info() - user = request.env.user - res.update( - { - "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/CONTRIBUTORS.md b/web_disable_export_group/readme/CONTRIBUTORS.md index 95560381e..ce5a705b2 100644 --- a/web_disable_export_group/readme/CONTRIBUTORS.md +++ b/web_disable_export_group/readme/CONTRIBUTORS.md @@ -7,3 +7,4 @@ - Alexandre Díaz - Víctor Martínez - David Vidal +- SodexisTeam diff --git a/web_disable_export_group/static/description/index.html b/web_disable_export_group/static/description/index.html index 7176c4d69..2230e16be 100644 --- a/web_disable_export_group/static/description/index.html +++ b/web_disable_export_group/static/description/index.html @@ -436,6 +436,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
  • David Vidal
  • +
  • SodexisTeam dev@sodexis.com
  • diff --git a/web_disable_export_group/static/src/js/abstract_controller.esm.js b/web_disable_export_group/static/src/js/abstract_controller.esm.js deleted file mode 100644 index 8576a18a2..000000000 --- a/web_disable_export_group/static/src/js/abstract_controller.esm.js +++ /dev/null @@ -1,26 +0,0 @@ -/** @odoo-module **/ -/* Copyright 2016 Onestein - Copyright 2018 Tecnativa - David Vidal - Copyright 2021 Tecnativa - Alexandre Díaz - Copyright 2022 Tecnativa - Víctor Martínez - License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ -import AbstractController from "web.AbstractController"; -import session from "web.session"; - -AbstractController.include({ - /** - * @override - */ - is_action_enabled: function (action) { - if ( - !session.is_superuser && - action && - action === "export_xlsx" && - !session.group_xlsx_export_data - ) { - return false; - } - - return this._super.apply(this, arguments); - }, -}); diff --git a/web_disable_export_group/static/src/js/export_all.esm.js b/web_disable_export_group/static/src/js/export_all.esm.js new file mode 100644 index 000000000..b25252739 --- /dev/null +++ b/web_disable_export_group/static/src/js/export_all.esm.js @@ -0,0 +1,20 @@ +/** @odoo-module **/ +/* Copyright 2018 Tecnativa - David Vidal + License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ +import {archParseBoolean} from "@web/views/utils"; +import {exportAllItem} from "@web/views/list/export_all/export_all"; +import {patch} from "@web/core/utils/patch"; + +patch(exportAllItem, { + async isDisplayed(env) { + const export_enable = await super.isDisplayed(...arguments); + const export_xls_enable = + env.config.viewType === "list" && + !env.model.root.selection.length && + (await env.model.user.hasGroup( + "web_disable_export_group.group_export_xlsx_data" + )) && + archParseBoolean(env.config.viewArch.getAttribute("export_xlsx"), true); + return export_xls_enable || export_enable; + }, +}); diff --git a/web_disable_export_group/static/src/js/list_controller.esm.js b/web_disable_export_group/static/src/js/list_controller.esm.js deleted file mode 100644 index 8e99b9148..000000000 --- a/web_disable_export_group/static/src/js/list_controller.esm.js +++ /dev/null @@ -1,20 +0,0 @@ -/** @odoo-module **/ -/* Copyright 2018 Tecnativa - David Vidal - License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ -import {ListController} from "@web/views/list/list_controller"; -import {onWillStart} from "@odoo/owl"; -import {patch} from "@web/core/utils/patch"; - -patch(ListController.prototype, "disable_export_group", { - setup() { - this._super(...arguments); - onWillStart(async () => { - this.isExportEnable = await this.userService.hasGroup( - "base.group_allow_export" - ); - this.isExportXlsEnable = await this.userService.hasGroup( - "web_disable_export_group.group_export_xlsx_data" - ); - }); - }, -}); diff --git a/web_disable_export_group/static/src/xml/export_xls_views.xml b/web_disable_export_group/static/src/xml/export_xls_views.xml deleted file mode 100644 index 236efcb32..000000000 --- a/web_disable_export_group/static/src/xml/export_xls_views.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - nbTotal and !nbSelected and activeActions.exportXlsx and isExportXlsEnable and !env.isSmall - - - - diff --git a/web_disable_export_group/static/tests/web_disable_export_group_tour.esm.js b/web_disable_export_group/static/tests/web_disable_export_group_tour.esm.js index 1702df8d6..14245c816 100644 --- a/web_disable_export_group/static/tests/web_disable_export_group_tour.esm.js +++ b/web_disable_export_group/static/tests/web_disable_export_group_tour.esm.js @@ -3,31 +3,42 @@ Copyright 2022 Tecnativa - Víctor Martínez License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ -import tour from "web_tour.tour"; +import {registry} from "@web/core/registry"; + +registry.category("web_tour.tours").add("export_tour_xlsx_button_ok", { + test: true, + url: "/web#model=ir.ui.view&view_type=list&cids=&action=base.action_ui_view", + + steps: () => [ + { + content: "Open the dropdown to find 'Export All' button", + trigger: ".o_cp_action_menus button.dropdown-toggle", + run: "click", + }, -tour.register( - "export_tour_xlsx_button_ok", - { - test: true, - url: "/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)", + trigger: ".dropdown-menu:has(.o_export_all_menu)", + run: function () { + console.log("Export All button found"); + }, + }, + ], +}); + +registry.category("web_tour.tours").add("export_tour_xlsx_button_ko", { + test: true, + url: "/web#model=ir.ui.view&view_type=list&cids=&action=base.action_ui_view", + + steps: () => [ + { + content: "Open the dropdown to find 'Export All' button", + trigger: ".o_cp_action_menus button.dropdown-toggle", + run: "click", }, - ] -); -tour.register( - "export_tour_xlsx_button_ko", - { - test: true, - url: "/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))", + trigger: ".dropdown-menu:not(:has(.o_export_all_menu))", }, - ] -); + ], +});