David
7 years ago
committed by
tarteo
12 changed files with 135 additions and 51 deletions
-
85web_disable_export_group/README.rst
-
4web_disable_export_group/__init__.py
-
15web_disable_export_group/__manifest__.py
-
1web_disable_export_group/models/__init__.py
-
18web_disable_export_group/models/ir_http.py
-
2web_disable_export_group/readme/CONFIGURE.rst
-
8web_disable_export_group/readme/CONTRIBUTORS.rst
-
7web_disable_export_group/readme/DESCRIPTION.rst
-
1web_disable_export_group/readme/USAGE.rst
-
2web_disable_export_group/security/groups.xml
-
40web_disable_export_group/static/src/js/disable_export_group.js
-
3web_disable_export_group/templates/assets.xml
@ -1,3 +1 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016 Onestein (<http://www.onestein.eu>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
from . import models |
@ -0,0 +1 @@ |
|||
from . import ir_http |
@ -0,0 +1,18 @@ |
|||
# 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(Http, self).session_info() |
|||
user = request.env.user |
|||
res.update({ |
|||
'group_export_data': user and user.has_group( |
|||
'web_disable_export_group.group_export_data'), |
|||
}) |
|||
return res |
@ -0,0 +1,2 @@ |
|||
Enable the group "Export Data group" to the users who are allowed to |
|||
make use of the option 'Export'. |
@ -0,0 +1,8 @@ |
|||
* `Onestein <https://www.onestein.nl>`_: |
|||
|
|||
* Dennis Sluijk <d.sluijk@onestein.nl> |
|||
* Andrea Stirpe <a.stirpe@onestein.nl> |
|||
|
|||
* `Tecnativa <https://www.tecnativa.com>`_: |
|||
|
|||
* David Vidal <david.vidal@tecnativa.com> |
@ -0,0 +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). |
|||
|
|||
This module makes the option 'Export' enabled only for the users that belong |
|||
to the Export Data group. |
|||
|
|||
Admin user can always use the export option. |
@ -0,0 +1 @@ |
|||
Every user without *Export Data* permission won't have the option available. |
@ -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); |
|||
}, |
|||
}); |
|||
}); |
Write
Preview
Loading…
Cancel
Save
Reference in new issue