diff --git a/setup/web_disable_export_group/odoo/addons/web_disable_export_group b/setup/web_disable_export_group/odoo/addons/web_disable_export_group new file mode 120000 index 000000000..d8a2f35c1 --- /dev/null +++ b/setup/web_disable_export_group/odoo/addons/web_disable_export_group @@ -0,0 +1 @@ +../../../../web_disable_export_group \ No newline at end of file diff --git a/setup/web_disable_export_group/setup.py b/setup/web_disable_export_group/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_disable_export_group/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_disable_export_group/README.rst b/web_disable_export_group/README.rst new file mode 100644 index 000000000..c1afee4fc --- /dev/null +++ b/web_disable_export_group/README.rst @@ -0,0 +1,100 @@ +======================== +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/13.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-13-0/web-13-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/13.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 +and the 'Export All' button of any list view is always enabled (for every user). + +This module makes the option 'Export' and 'Export All' enabled only for the users +that belong to the Export Data group. + +Admin user can always use the export option. + +**Table of contents** + +.. 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 +======= + +Authors +~~~~~~~ + +* Onestein +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Onestein `_: + + * Dennis Sluijk + * Andrea Stirpe + +* `Tecnativa `_: + + * David Vidal + * João Marques + * Alexandre Díaz + +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. + +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 new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/web_disable_export_group/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/web_disable_export_group/__manifest__.py b/web_disable_export_group/__manifest__.py new file mode 100644 index 000000000..7a4be4db9 --- /dev/null +++ b/web_disable_export_group/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2016 Onestein () +# Copyright 2018 Tecnativa - David Vidal +# Copyright 2018 Tecnativa - João Marques +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Web Disable Export Group", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "author": "Onestein, " "Tecnativa, " "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/web", + "category": "Web", + "depends": ["web"], + "data": [ + "security/groups.xml", + "templates/assets.xml", + "templates/tour_assets.xml", + ], + "installable": True, +} diff --git a/web_disable_export_group/i18n/es.po b/web_disable_export_group/i18n/es.po new file mode 100644 index 000000000..a6de3e09e --- /dev/null +++ b/web_disable_export_group/i18n/es.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_disable_export_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-07-23 14:19+0000\n" +"Last-Translator: claudiagn \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: web_disable_export_group +#. openerp-web +#: code:addons/web_disable_export_group/static/src/js/disable_export_group.js:0 +#: code:addons/web_disable_export_group/static/src/js/web_disable_export_group_tour.js:0 +#, python-format +msgid "Export" +msgstr "Exportar" + +#. module: web_disable_export_group +#: model:res.groups,name:web_disable_export_group.group_export_data +msgid "Export Data" +msgstr "Exportar datos" + +#. module: web_disable_export_group +#: model:ir.model,name:web_disable_export_group.model_ir_http +msgid "HTTP Routing" +msgstr "Ruta HTTP" diff --git a/web_disable_export_group/i18n/hr.po b/web_disable_export_group/i18n/hr.po new file mode 100644 index 000000000..26041bf6d --- /dev/null +++ b/web_disable_export_group/i18n/hr.po @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_disable_export_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-12-02 16:35+0000\n" +"Last-Translator: Bole \n" +"Language-Team: none\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Weblate 3.9.1\n" + +#. module: web_disable_export_group +#. openerp-web +#: code:addons/web_disable_export_group/static/src/js/disable_export_group.js:0 +#: code:addons/web_disable_export_group/static/src/js/web_disable_export_group_tour.js:0 +#, python-format +msgid "Export" +msgstr "Izvoz" + +#. module: web_disable_export_group +#: model:res.groups,name:web_disable_export_group.group_export_data +msgid "Export Data" +msgstr "Izvoz podataka" + +#. module: web_disable_export_group +#: model:ir.model,name:web_disable_export_group.model_ir_http +msgid "HTTP Routing" +msgstr "HTTP usmjeravanje" diff --git a/web_disable_export_group/i18n/pt.po b/web_disable_export_group/i18n/pt.po new file mode 100644 index 000000000..e379d0bd9 --- /dev/null +++ b/web_disable_export_group/i18n/pt.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_disable_export_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-10-16 12:08+0000\n" +"Last-Translator: Pedro Castro Silva \n" +"Language-Team: none\n" +"Language: pt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: web_disable_export_group +#. openerp-web +#: code:addons/web_disable_export_group/static/src/js/disable_export_group.js:0 +#: code:addons/web_disable_export_group/static/src/js/web_disable_export_group_tour.js:0 +#, python-format +msgid "Export" +msgstr "Exportar" + +#. module: web_disable_export_group +#: model:res.groups,name:web_disable_export_group.group_export_data +msgid "Export Data" +msgstr "Exportar Dados" + +#. module: web_disable_export_group +#: model:ir.model,name:web_disable_export_group.model_ir_http +msgid "HTTP Routing" +msgstr "Encaminhamento HTTP" 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 000000000..80395d288 --- /dev/null +++ b/web_disable_export_group/i18n/web_disable_export_group.pot @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_disable_export_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.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:0 +#: code:addons/web_disable_export_group/static/src/js/web_disable_export_group_tour.js:0 +#: code:addons/web_disable_export_group/static/src/js/web_disable_export_group_tour.js:0 +#, 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/i18n/zh_CN.po b/web_disable_export_group/i18n/zh_CN.po new file mode 100644 index 000000000..203977350 --- /dev/null +++ b/web_disable_export_group/i18n/zh_CN.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_disable_export_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-09-01 12:52+0000\n" +"Last-Translator: 黎伟杰 <674416404@qq.com>\n" +"Language-Team: none\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 3.8\n" + +#. module: web_disable_export_group +#. openerp-web +#: code:addons/web_disable_export_group/static/src/js/disable_export_group.js:0 +#: code:addons/web_disable_export_group/static/src/js/web_disable_export_group_tour.js:0 +#, 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 "HTTP路由" diff --git a/web_disable_export_group/models/__init__.py b/web_disable_export_group/models/__init__.py new file mode 100644 index 000000000..9a5eb7187 --- /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 000000000..156f13160 --- /dev/null +++ b/web_disable_export_group/models/ir_http.py @@ -0,0 +1,20 @@ +# 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_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 000000000..df6b1e4b7 --- /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 000000000..d34bdc8b6 --- /dev/null +++ b/web_disable_export_group/readme/CONTRIBUTORS.rst @@ -0,0 +1,10 @@ +* `Onestein `_: + + * Dennis Sluijk + * Andrea Stirpe + +* `Tecnativa `_: + + * David Vidal + * João Marques + * Alexandre Díaz diff --git a/web_disable_export_group/readme/DESCRIPTION.rst b/web_disable_export_group/readme/DESCRIPTION.rst new file mode 100644 index 000000000..fc67346c3 --- /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 +and the 'Export All' button of any list view is always enabled (for every user). + +This module makes the option 'Export' and 'Export All' 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 000000000..9e1706a1b --- /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 new file mode 100644 index 000000000..548e4c051 --- /dev/null +++ b/web_disable_export_group/security/groups.xml @@ -0,0 +1,12 @@ + + + + + Export Data + + + diff --git a/web_disable_export_group/static/description/icon.png b/web_disable_export_group/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_disable_export_group/static/description/icon.png differ 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 000000000..7fe27df04 --- /dev/null +++ b/web_disable_export_group/static/description/index.html @@ -0,0 +1,445 @@ + + + + + + +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 +and the ‘Export All’ button of any list view is always enabled (for every user).

+

This module makes the option ‘Export’ and ‘Export All’ 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 new file mode 100644 index 000000000..a94763f0e --- /dev/null +++ b/web_disable_export_group/static/src/js/disable_export_group.js @@ -0,0 +1,49 @@ +/* Copyright 2016 Onestein + Copyright 2018 Tecnativa - David Vidal + Copyright 2021 Tecnativa - Alexandre Díaz + License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ +odoo.define("web_disable_export_group", function (require) { + "use strict"; + + const core = require("web.core"); + const Sidebar = require("web.Sidebar"); + const session = require("web.session"); + const AbstractController = require("web.AbstractController"); + const _t = core._t; + + Sidebar.include({ + /** + * @override + */ + _addItems: function (sectionCode, items) { + let _items = items; + if ( + !session.is_superuser && + sectionCode === "other" && + items.length && + !session.group_export_data + ) { + _items = _.reject(_items, {label: _t("Export")}); + } + this._super(sectionCode, _items); + }, + }); + + AbstractController.include({ + /** + * @override + */ + is_action_enabled: function (action) { + if ( + !session.is_superuser && + action && + action.startsWith("export_") && + !session.group_export_data + ) { + return false; + } + + return this._super.apply(this, arguments); + }, + }); +}); diff --git a/web_disable_export_group/static/src/js/web_disable_export_group_tour.js b/web_disable_export_group/static/src/js/web_disable_export_group_tour.js new file mode 100644 index 000000000..d93b75ac6 --- /dev/null +++ b/web_disable_export_group/static/src/js/web_disable_export_group_tour.js @@ -0,0 +1,71 @@ +/* Copyright 2020 Tecnativa - João Marques + License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ + +odoo.define("web_disable_export_group.tour", function (require) { + "use strict"; + + var core = require("web.core"); + var tour = require("web_tour.tour"); + + var _t = core._t; + + tour.register( + "export_tour_admin", + { + 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)", + }, + { + content: "Select all records", + trigger: ".custom-control-input:first", + }, + { + content: "Open actions", + trigger: ".o_dropdown_toggler_btn", + }, + { + content: "Check if Export button exists", + trigger: + '.o_cp_action_menus ul.o_dropdown_menu a:contains("' + + _t("Export") + + '")', + }, + ] + ); + tour.register( + "export_tour_demo", + { + 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))", + }, + { + content: "Select all records", + trigger: ".custom-control-input:first", + }, + { + content: "Open actions", + trigger: ".o_dropdown_toggler_btn", + }, + { + content: "Check if Export button does not exist", + trigger: + '.o_cp_action_menus ul.o_dropdown_menu a:first:not(:contains("' + + _t("Export") + + '"))', + }, + ] + ); + return {}; +}); diff --git a/web_disable_export_group/templates/assets.xml b/web_disable_export_group/templates/assets.xml new file mode 100644 index 000000000..ec5155977 --- /dev/null +++ b/web_disable_export_group/templates/assets.xml @@ -0,0 +1,17 @@ + + + +