[IMP] web_disable_export_group: Differenciate between the XLSX export and the standard export

This commit is contained in:
Enric Tobella
2021-10-26 17:06:13 +02:00
committed by David
parent f1fe2a9547
commit dc35109185
18 changed files with 166 additions and 153 deletions

View File

@@ -368,10 +368,8 @@ ul.auto-toc {
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/14.0/web_disable_export_group"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-14-0/web-14-0-web_disable_export_group"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>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).</p>
<p>This module makes the option Export and Export All enabled only for the users
that belong to the Export Data group.</p>
<p>The standard export group prevents both options: Direct Export (xlsx) and Export All.</p>
<p>This module adds a new group for the Direct Export (xlsx) feature, leaving the standard one for only the Export All feature.</p>
<p>Admin user can always use the export option.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
@@ -389,12 +387,12 @@ that belong to the Export Data group.</p>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>Enable the group “Export Data group” to the users who are allowed to
make use of the option Export.</p>
<p>Enable the group “Direct Export” to the users who are allowed to
make use of the option Export xlsx.</p>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
<p>Every user without <em>Export Data</em> permission wont have the option available.</p>
<p>Every user without <em>Direct Export (xlsx)</em> permission wont have the option available.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
@@ -425,6 +423,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>David Vidal</li>
<li>João Marques</li>
<li>Alexandre Díaz</li>
<li>Víctor Martínez</li>
</ul>
</li>
</ul>

View File

@@ -1,33 +1,15 @@
/* 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). */
odoo.define("web_disable_export_group", function (require) {
odoo.define("web_disable_export_group.WebDisableExportGroupController", function (
require
) {
"use strict";
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) {
let _items = items;
if (
!session.is_superuser &&
sectionCode === "other" &&
items.length &&
!session.group_export_data
) {
_items = _.reject(_items, {label: _t("Export")});
}
this._super(sectionCode, _items);
},
});
AbstractController.include({
/**
@@ -37,8 +19,8 @@ odoo.define("web_disable_export_group", function (require) {
if (
!session.is_superuser &&
action &&
action.startsWith("export_") &&
!session.group_export_data
action.startsWith("export_xlsx") &&
!session.group_xlsx_export_data
) {
return false;
}

View File

@@ -1,16 +1,14 @@
/* Copyright 2020 Tecnativa - João Marques
Copyright 2022 Tecnativa - Víctor Martínez
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */
odoo.define("web_disable_export_group.tour", function (require) {
"use strict";
var core = require("web.core");
var tour = require("web_tour.tour");
var _t = core._t;
tour.register(
"export_tour_admin",
"export_tour_xlsx_button_ok",
{
test: true,
url:
@@ -21,25 +19,10 @@ odoo.define("web_disable_export_group.tour", function (require) {
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",
},
{
content: "Open actions",
trigger: ".o_dropdown_toggler_btn",
},
{
content: "Check if Export button exists",
trigger:
'.o_cp_action_menus ul.o_dropdown_menu a:contains("' +
_t("Export") +
'")',
},
]
);
tour.register(
"export_tour_demo",
"export_tour_xlsx_button_ko",
{
test: true,
url:
@@ -50,21 +33,6 @@ odoo.define("web_disable_export_group.tour", function (require) {
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",
},
{
content: "Open actions",
trigger: ".o_dropdown_toggler_btn",
},
{
content: "Check if Export button does not exist",
trigger:
'.o_cp_action_menus ul.o_dropdown_menu a:first:not(:contains("' +
_t("Export") +
'"))',
},
]
);
return {};