mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[MIG] web_disable_group_export: Migration to 11.0
This commit is contained in:
@@ -1,41 +1,21 @@
|
||||
/* Copyright 2016 Onestein
|
||||
Copyright 2018 Tecnativa - David Vidal
|
||||
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 _t = core._t;
|
||||
var Model = require("web.Model");
|
||||
var session = require("web.session");
|
||||
var _t = core._t;
|
||||
|
||||
Sidebar.include({
|
||||
add_items: function(section_code, items) {
|
||||
var self = this;
|
||||
var _super = this._super;
|
||||
if (session.is_superuser) {
|
||||
_super.apply(this, arguments);
|
||||
} else {
|
||||
var model_res_users = new Model("res.users");
|
||||
model_res_users.call("has_group", ["web_disable_export_group.group_export_data"]).done(function(can_export) {
|
||||
if (!can_export) {
|
||||
var export_label = _t("Export");
|
||||
var new_items = items;
|
||||
if (section_code === "other") {
|
||||
new_items = [];
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
console.log("items[i]: ", items[i]);
|
||||
if (items[i]["label"] !== export_label) {
|
||||
new_items.push(items[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (new_items.length > 0) {
|
||||
_super.call(self, section_code, new_items);
|
||||
}
|
||||
} else {
|
||||
_super.call(self, section_code, items);
|
||||
}
|
||||
});
|
||||
_addItems: function (sectionCode, items) {
|
||||
var _items = items;
|
||||
if (!session.is_superuser && sectionCode === 'other' && items.length && !session.group_export_data) {
|
||||
_items = _.reject(_items, {label:_t("Export")});
|
||||
}
|
||||
}
|
||||
this._super(sectionCode, _items);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user