From 0864b227b2cc9c9ae7013d7cdc31cb65235fc555 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 27 Dec 2016 10:31:18 +0100 Subject: [PATCH 01/26] Add module web_disable_export_group --- web_disable_export_group/README.rst | 35 ++++++++++++++++ web_disable_export_group/__init__.py | 3 ++ web_disable_export_group/__manifest__.py | 18 ++++++++ web_disable_export_group/security/groups.xml | 8 ++++ .../static/src/js/disable_export_group.js | 41 +++++++++++++++++++ web_disable_export_group/templates/assets.xml | 10 +++++ 6 files changed, 115 insertions(+) create mode 100644 web_disable_export_group/README.rst create mode 100644 web_disable_export_group/__init__.py create mode 100644 web_disable_export_group/__manifest__.py create mode 100644 web_disable_export_group/security/groups.xml create mode 100644 web_disable_export_group/static/src/js/disable_export_group.js create mode 100644 web_disable_export_group/templates/assets.xml diff --git a/web_disable_export_group/README.rst b/web_disable_export_group/README.rst new file mode 100644 index 000000000000..3eee5cecba1e --- /dev/null +++ b/web_disable_export_group/README.rst @@ -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 +* Andrea Stirpe diff --git a/web_disable_export_group/__init__.py b/web_disable_export_group/__init__.py new file mode 100644 index 000000000000..9b9ad0f122dd --- /dev/null +++ b/web_disable_export_group/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Onestein () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/web_disable_export_group/__manifest__.py b/web_disable_export_group/__manifest__.py new file mode 100644 index 000000000000..32e48d5c6a1b --- /dev/null +++ b/web_disable_export_group/__manifest__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Onestein () +# 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, +} diff --git a/web_disable_export_group/security/groups.xml b/web_disable_export_group/security/groups.xml new file mode 100644 index 000000000000..b06e8e83a295 --- /dev/null +++ b/web_disable_export_group/security/groups.xml @@ -0,0 +1,8 @@ + + + + + Export Data + + + diff --git a/web_disable_export_group/static/src/js/disable_export_group.js b/web_disable_export_group/static/src/js/disable_export_group.js new file mode 100644 index 000000000000..2f5740e5a539 --- /dev/null +++ b/web_disable_export_group/static/src/js/disable_export_group.js @@ -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); + } + }); + } + } + }); +}); diff --git a/web_disable_export_group/templates/assets.xml b/web_disable_export_group/templates/assets.xml new file mode 100644 index 000000000000..e9fe7f05ad9f --- /dev/null +++ b/web_disable_export_group/templates/assets.xml @@ -0,0 +1,10 @@ + + + + + + From 7c5b51641bf65025a0a49cd91e3469077e2f8df6 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 16 Jul 2018 12:07:52 +0200 Subject: [PATCH 02/26] [MIG] web_disable_group_export: Migration to 11.0 --- web_disable_export_group/README.rst | 85 +++- web_disable_export_group/__init__.py | 4 +- web_disable_export_group/__manifest__.py | 15 +- .../i18n/web_disable_export_group.pot | 32 ++ web_disable_export_group/models/__init__.py | 1 + web_disable_export_group/models/ir_http.py | 18 + web_disable_export_group/readme/CONFIGURE.rst | 2 + .../readme/CONTRIBUTORS.rst | 8 + .../readme/DESCRIPTION.rst | 7 + web_disable_export_group/readme/USAGE.rst | 1 + web_disable_export_group/security/groups.xml | 2 + .../static/description/index.html | 443 ++++++++++++++++++ .../static/src/js/disable_export_group.js | 40 +- web_disable_export_group/templates/assets.xml | 3 +- 14 files changed, 610 insertions(+), 51 deletions(-) create mode 100644 web_disable_export_group/i18n/web_disable_export_group.pot create mode 100644 web_disable_export_group/models/__init__.py create mode 100644 web_disable_export_group/models/ir_http.py create mode 100644 web_disable_export_group/readme/CONFIGURE.rst create mode 100644 web_disable_export_group/readme/CONTRIBUTORS.rst create mode 100644 web_disable_export_group/readme/DESCRIPTION.rst create mode 100644 web_disable_export_group/readme/USAGE.rst create mode 100644 web_disable_export_group/static/description/index.html diff --git a/web_disable_export_group/README.rst b/web_disable_export_group/README.rst index 3eee5cecba1e..374c44c239d1 100644 --- a/web_disable_export_group/README.rst +++ b/web_disable_export_group/README.rst @@ -1,11 +1,30 @@ -.. 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 ======================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/11.0/web_disable_export_group + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-11-0/web-11-0-web_disable_export_group + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/162/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + 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). @@ -14,22 +33,66 @@ to the Export Data group. Admin user can always use the export option. +**Table of contents** -Usage -===== +.. contents:: + :local: + +Configuration +============= Enable the group "Export Data group" to the users who are allowed to make use of the option 'Export'. +Usage +===== + +Every user without *Export Data* permission won't have the option available. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= -Original code from module web_disable_export by Noviat, -reviewed and modified by Onestein. +Authors +~~~~~~~ + +* Onestein +* Tecnativa Contributors ------------- +~~~~~~~~~~~~ + +* `Onestein `_: + + * Dennis Sluijk + * Andrea Stirpe + +* `Tecnativa `_: + + * David Vidal + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/web `_ project on GitHub. -* Dennis Sluijk -* Andrea Stirpe +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_disable_export_group/__init__.py b/web_disable_export_group/__init__.py index 9b9ad0f122dd..0650744f6bc6 100644 --- a/web_disable_export_group/__init__.py +++ b/web_disable_export_group/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- -# Copyright 2016 Onestein () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import models diff --git a/web_disable_export_group/__manifest__.py b/web_disable_export_group/__manifest__.py index 32e48d5c6a1b..1a9f0c36ae02 100644 --- a/web_disable_export_group/__manifest__.py +++ b/web_disable_export_group/__manifest__.py @@ -1,15 +1,18 @@ -# -*- coding: utf-8 -*- # Copyright 2016 Onestein () +# Copyright 2018 Tecnativa - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - { 'name': 'Web Disable Export Group', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'license': 'AGPL-3', - 'author': 'Onestein', - 'website': 'http://www.onestein.eu', + 'author': 'Onestein, ' + 'Tecnativa, ' + 'Odoo Community Association (OCA)', + 'website': 'http://www.github.com/OCA/web', 'category': 'Web', - 'depends': ['web'], + 'depends': [ + 'web', + ], 'data': [ 'security/groups.xml', 'templates/assets.xml', diff --git a/web_disable_export_group/i18n/web_disable_export_group.pot b/web_disable_export_group/i18n/web_disable_export_group.pot new file mode 100644 index 000000000000..d588f0655d93 --- /dev/null +++ b/web_disable_export_group/i18n/web_disable_export_group.pot @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_disable_export_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: web_disable_export_group +#. openerp-web +#: code:addons/web_disable_export_group/static/src/js/disable_export_group.js:16 +#, python-format +msgid "Export" +msgstr "" + +#. module: web_disable_export_group +#: model:res.groups,name:web_disable_export_group.group_export_data +msgid "Export Data" +msgstr "" + +#. module: web_disable_export_group +#: model:ir.model,name:web_disable_export_group.model_ir_http +msgid "HTTP routing" +msgstr "" + diff --git a/web_disable_export_group/models/__init__.py b/web_disable_export_group/models/__init__.py new file mode 100644 index 000000000000..9a5eb71871d4 --- /dev/null +++ b/web_disable_export_group/models/__init__.py @@ -0,0 +1 @@ +from . import ir_http diff --git a/web_disable_export_group/models/ir_http.py b/web_disable_export_group/models/ir_http.py new file mode 100644 index 000000000000..1ce239b403e5 --- /dev/null +++ b/web_disable_export_group/models/ir_http.py @@ -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 diff --git a/web_disable_export_group/readme/CONFIGURE.rst b/web_disable_export_group/readme/CONFIGURE.rst new file mode 100644 index 000000000000..df6b1e4b7352 --- /dev/null +++ b/web_disable_export_group/readme/CONFIGURE.rst @@ -0,0 +1,2 @@ +Enable the group "Export Data group" to the users who are allowed to +make use of the option 'Export'. diff --git a/web_disable_export_group/readme/CONTRIBUTORS.rst b/web_disable_export_group/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..69dbb60098ae --- /dev/null +++ b/web_disable_export_group/readme/CONTRIBUTORS.rst @@ -0,0 +1,8 @@ +* `Onestein `_: + + * Dennis Sluijk + * Andrea Stirpe + +* `Tecnativa `_: + + * David Vidal diff --git a/web_disable_export_group/readme/DESCRIPTION.rst b/web_disable_export_group/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..ecc454e24b71 --- /dev/null +++ b/web_disable_export_group/readme/DESCRIPTION.rst @@ -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. diff --git a/web_disable_export_group/readme/USAGE.rst b/web_disable_export_group/readme/USAGE.rst new file mode 100644 index 000000000000..9e1706a1b0a6 --- /dev/null +++ b/web_disable_export_group/readme/USAGE.rst @@ -0,0 +1 @@ +Every user without *Export Data* permission won't have the option available. diff --git a/web_disable_export_group/security/groups.xml b/web_disable_export_group/security/groups.xml index b06e8e83a295..b5e0d65280a5 100644 --- a/web_disable_export_group/security/groups.xml +++ b/web_disable_export_group/security/groups.xml @@ -1,4 +1,6 @@ + diff --git a/web_disable_export_group/static/description/index.html b/web_disable_export_group/static/description/index.html new file mode 100644 index 000000000000..574d7458206d --- /dev/null +++ b/web_disable_export_group/static/description/index.html @@ -0,0 +1,443 @@ + + + + + + +Web Disable Export Group + + + +
+

Web Disable Export Group

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

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.

+

Table of contents

+ +
+

Configuration

+

Enable the group “Export Data group” to the users who are allowed to +make use of the option ‘Export’.

+
+
+

Usage

+

Every user without Export Data permission won’t have the option available.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Onestein
  • +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/web_disable_export_group/static/src/js/disable_export_group.js b/web_disable_export_group/static/src/js/disable_export_group.js index 2f5740e5a539..6c26f9e644ce 100644 --- a/web_disable_export_group/static/src/js/disable_export_group.js +++ b/web_disable_export_group/static/src/js/disable_export_group.js @@ -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); + }, }); }); diff --git a/web_disable_export_group/templates/assets.xml b/web_disable_export_group/templates/assets.xml index e9fe7f05ad9f..90d171c0de36 100644 --- a/web_disable_export_group/templates/assets.xml +++ b/web_disable_export_group/templates/assets.xml @@ -1,6 +1,7 @@ + -