mirror of https://github.com/OCA/web.git
Add module web_disable_export_group
parent
704a643346
commit
9023bca634
|
@ -0,0 +1,35 @@
|
||||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||||
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
|
:alt: License: AGPL-3
|
||||||
|
|
||||||
|
========================
|
||||||
|
Web Disable Export Group
|
||||||
|
========================
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
Usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
Enable the group "Export Data group" to the users who are allowed to
|
||||||
|
make use of the option 'Export'.
|
||||||
|
|
||||||
|
|
||||||
|
Credits
|
||||||
|
=======
|
||||||
|
|
||||||
|
Original code from module web_disable_export by Noviat,
|
||||||
|
reviewed and modified by Onestein.
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
------------
|
||||||
|
|
||||||
|
* Dennis Sluijk <d.sluijk@onestein.nl>
|
||||||
|
* Andrea Stirpe <a.stirpe@onestein.nl>
|
|
@ -0,0 +1,3 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2016 Onestein (<http://www.onestein.eu>)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
@ -0,0 +1,18 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2016 Onestein (<http://www.onestein.eu>)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': 'Web Disable Export Group',
|
||||||
|
'version': '10.0.1.0.0',
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
'author': 'Onestein',
|
||||||
|
'website': 'http://www.onestein.eu',
|
||||||
|
'category': 'Web',
|
||||||
|
'depends': ['web'],
|
||||||
|
'data': [
|
||||||
|
'security/groups.xml',
|
||||||
|
'templates/assets.xml',
|
||||||
|
],
|
||||||
|
'installable': True,
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="group_export_data" model="res.groups">
|
||||||
|
<field name="name">Export Data</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
|
@ -0,0 +1,41 @@
|
||||||
|
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");
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<template id="assets_backend" name="web_disable_export_group assets" inherit_id="web.assets_backend">
|
||||||
|
<xpath expr="." position="inside">
|
||||||
|
<script type="text/javascript" src="/web_disable_export_group/static/src/js/disable_export_group.js"></script>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</odoo>
|
Loading…
Reference in New Issue