mirror of https://github.com/OCA/web.git
[MIG] web_disable_export_group: Migration to 17.0
parent
72ec86fecb
commit
ae8436cf98
|
@ -90,6 +90,8 @@ Contributors
|
|||
- Víctor Martínez
|
||||
- David Vidal
|
||||
|
||||
- SodexisTeam dev@sodexis.com
|
||||
|
||||
Maintainers
|
||||
-----------
|
||||
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
from . import ir_http
|
||||
from . import models
|
||||
|
|
|
@ -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
|
|
@ -7,3 +7,4 @@
|
|||
- Alexandre Díaz
|
||||
- Víctor Martínez
|
||||
- David Vidal
|
||||
- SodexisTeam <dev@sodexis.com>
|
||||
|
|
|
@ -436,6 +436,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|||
<li>David Vidal</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>SodexisTeam <a class="reference external" href="mailto:dev@sodexis.com">dev@sodexis.com</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
});
|
|
@ -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;
|
||||
},
|
||||
});
|
|
@ -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"
|
||||
);
|
||||
});
|
||||
},
|
||||
});
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<templates>
|
||||
|
||||
<t
|
||||
t-name="web.ListView.Buttons.disbaleExport"
|
||||
t-inherit="web.ListView.Buttons"
|
||||
t-inherit-mode="extension"
|
||||
owl="1"
|
||||
>
|
||||
<xpath expr="//t[contains(@t-if, 'isExportEnable')]" position="attributes">
|
||||
<attribute
|
||||
name="t-if"
|
||||
>nbTotal and !nbSelected and activeActions.exportXlsx and isExportXlsEnable and !env.isSmall</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
|
@ -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))",
|
||||
},
|
||||
]
|
||||
);
|
||||
],
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue