From bb8608c90ec01c4bd6931d3724706435d12711bc Mon Sep 17 00:00:00 2001 From: David Date: Wed, 21 Jun 2023 17:17:23 +0200 Subject: [PATCH] [MIG] web_disable_export_group: Migration to 15.0 TT43531 --- web_disable_export_group/README.rst | 40 +++++++----- web_disable_export_group/__manifest__.py | 10 ++- web_disable_export_group/i18n/es.po | 19 +++--- web_disable_export_group/i18n/hr.po | 19 +++--- web_disable_export_group/i18n/pt.po | 19 +++--- .../i18n/web_disable_export_group.pot | 21 +++--- web_disable_export_group/i18n/zh_CN.po | 19 +++--- .../migrations/14.0.1.1.0/pre-migration.py | 16 ----- web_disable_export_group/models/__init__.py | 1 + web_disable_export_group/models/models.py | 23 +++++++ web_disable_export_group/readme/CONFIGURE.rst | 4 +- .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 8 ++- web_disable_export_group/readme/USAGE.rst | 4 +- web_disable_export_group/security/groups.xml | 7 +- .../security/ir.model.access.csv | 2 + .../static/description/index.html | 65 +++++++++++-------- .../static/src/js/abstract_controller.esm.js | 26 ++++++++ .../static/src/js/disable_export_group.js | 31 --------- .../static/src/js/list_controller.esm.js | 19 ++++++ .../src/js/web_disable_export_group_tour.js | 39 ----------- .../web_disable_export_group_tour.esm.js | 33 ++++++++++ .../static/src/xml/export_xls_views.xml | 12 ++++ web_disable_export_group/templates/assets.xml | 17 ----- .../templates/tour_assets.xml | 17 ----- 25 files changed, 242 insertions(+), 230 deletions(-) delete mode 100644 web_disable_export_group/migrations/14.0.1.1.0/pre-migration.py create mode 100644 web_disable_export_group/models/models.py create mode 100644 web_disable_export_group/security/ir.model.access.csv create mode 100644 web_disable_export_group/static/src/js/abstract_controller.esm.js delete mode 100644 web_disable_export_group/static/src/js/disable_export_group.js create mode 100644 web_disable_export_group/static/src/js/list_controller.esm.js delete mode 100644 web_disable_export_group/static/src/js/web_disable_export_group_tour.js create mode 100644 web_disable_export_group/static/src/tours/web_disable_export_group_tour.esm.js create mode 100644 web_disable_export_group/static/src/xml/export_xls_views.xml delete mode 100644 web_disable_export_group/templates/assets.xml delete mode 100644 web_disable_export_group/templates/tour_assets.xml diff --git a/web_disable_export_group/README.rst b/web_disable_export_group/README.rst index 58ec4a2a2..c001e0e65 100644 --- a/web_disable_export_group/README.rst +++ b/web_disable_export_group/README.rst @@ -2,10 +2,13 @@ Web Disable Export Group ======================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:3f87e644dfcdd8674f909e10611703748bf60635999074fcd231cd8fc4bff4ea + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -14,22 +17,24 @@ Web Disable Export Group :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/14.0/web_disable_export_group + :target: https://github.com/OCA/web/tree/15.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-14-0/web-14-0-web_disable_export_group + :target: https://translation.odoo-community.org/projects/web-15-0/web-15-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/14.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=15.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| -The standard export group prevents both options: 'Direct Export (xlsx)' and 'Export All'. +The standard grants/prevents access to any UI export via *Access to export feature* +group. -This module adds a new group for the 'Direct Export (xlsx)' feature, leaving the standard one for only the 'Export All' feature. +This module adds a new group for the 'Direct Export (xlsx)' feature, leaving the +standard one for only the 'Export All' feature. -Admin user can always use the export option. +Admin users can always use the export option. **Table of contents** @@ -39,21 +44,23 @@ Admin user can always use the export option. Configuration ============= -Enable the group "Direct Export" to the users who are allowed to -make use of the option 'Export xlsx'. +Enable the group *Direct Export* to the users who are allowed to make use of the option +'Export xlsx' from the list view. Usage ===== -Every user without *Direct Export (xlsx)* permission won't have the option available. +- Users in the *Access to export feature* group or admins can export in any way. +- Users in the *Direct Export (xlsx)* group can only use the default export feature + from the list view. 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 `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -80,6 +87,7 @@ Contributors * João Marques * Alexandre Díaz * Víctor Martínez + * David Vidal Maintainers ~~~~~~~~~~~ @@ -94,6 +102,6 @@ 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. +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/__manifest__.py b/web_disable_export_group/__manifest__.py index f17a6f1b2..f4692f43b 100644 --- a/web_disable_export_group/__manifest__.py +++ b/web_disable_export_group/__manifest__.py @@ -4,7 +4,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Web Disable Export Group", - "version": "14.0.2.0.0", + "version": "15.0.2.0.0", "license": "AGPL-3", "author": "Onestein, Tecnativa, Odoo Community Association (OCA)", "website": "https://github.com/OCA/web", @@ -12,8 +12,12 @@ "depends": ["web"], "data": [ "security/groups.xml", - "templates/assets.xml", - "templates/tour_assets.xml", + "security/ir.model.access.csv", ], "installable": True, + "assets": { + "web.assets_backend": ["/web_disable_export_group/static/src/js/*.js"], + "web.assets_tests": ["/web_disable_export_group/static/src/tours/*.js"], + "web.assets_qweb": ["/web_disable_export_group/static/src/xml/**/*"], + }, } diff --git a/web_disable_export_group/i18n/es.po b/web_disable_export_group/i18n/es.po index 18b288f8c..78cab0291 100644 --- a/web_disable_export_group/i18n/es.po +++ b/web_disable_export_group/i18n/es.po @@ -17,13 +17,13 @@ msgstr "" "X-Generator: Weblate 3.10\n" #. module: web_disable_export_group -#: model:res.groups,name:web_disable_export_group.group_export_xlsx_data -msgid "Direct Export (xlsx)" +#: model:ir.model,name:web_disable_export_group.model_base +msgid "Base" msgstr "" #. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http__display_name -msgid "Display Name" +#: model:res.groups,name:web_disable_export_group.group_export_xlsx_data +msgid "Direct Export (xlsx)" msgstr "" #. module: web_disable_export_group @@ -32,13 +32,10 @@ msgid "HTTP Routing" msgstr "Ruta HTTP" #. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http__id -msgid "ID" -msgstr "" - -#. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http____last_update -msgid "Last Modified on" +#. openerp-web +#: code:addons/web_disable_export_group/static/src/xml/export_xls_views.xml:0 +#, python-format +msgid "widget.is_action_enabled('export_xlsx') and widget.isExportXlsEnable" msgstr "" #, python-format diff --git a/web_disable_export_group/i18n/hr.po b/web_disable_export_group/i18n/hr.po index 8d3f878c9..adfd1c42f 100644 --- a/web_disable_export_group/i18n/hr.po +++ b/web_disable_export_group/i18n/hr.po @@ -18,13 +18,13 @@ msgstr "" "X-Generator: Weblate 3.9.1\n" #. module: web_disable_export_group -#: model:res.groups,name:web_disable_export_group.group_export_xlsx_data -msgid "Direct Export (xlsx)" +#: model:ir.model,name:web_disable_export_group.model_base +msgid "Base" msgstr "" #. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http__display_name -msgid "Display Name" +#: model:res.groups,name:web_disable_export_group.group_export_xlsx_data +msgid "Direct Export (xlsx)" msgstr "" #. module: web_disable_export_group @@ -33,13 +33,10 @@ msgid "HTTP Routing" msgstr "HTTP usmjeravanje" #. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http__id -msgid "ID" -msgstr "" - -#. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http____last_update -msgid "Last Modified on" +#. openerp-web +#: code:addons/web_disable_export_group/static/src/xml/export_xls_views.xml:0 +#, python-format +msgid "widget.is_action_enabled('export_xlsx') and widget.isExportXlsEnable" msgstr "" #, python-format diff --git a/web_disable_export_group/i18n/pt.po b/web_disable_export_group/i18n/pt.po index 4a01169ac..5011adca8 100644 --- a/web_disable_export_group/i18n/pt.po +++ b/web_disable_export_group/i18n/pt.po @@ -17,13 +17,13 @@ msgstr "" "X-Generator: Weblate 3.10\n" #. module: web_disable_export_group -#: model:res.groups,name:web_disable_export_group.group_export_xlsx_data -msgid "Direct Export (xlsx)" +#: model:ir.model,name:web_disable_export_group.model_base +msgid "Base" msgstr "" #. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http__display_name -msgid "Display Name" +#: model:res.groups,name:web_disable_export_group.group_export_xlsx_data +msgid "Direct Export (xlsx)" msgstr "" #. module: web_disable_export_group @@ -32,13 +32,10 @@ msgid "HTTP Routing" msgstr "Encaminhamento HTTP" #. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http__id -msgid "ID" -msgstr "" - -#. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http____last_update -msgid "Last Modified on" +#. openerp-web +#: code:addons/web_disable_export_group/static/src/xml/export_xls_views.xml:0 +#, python-format +msgid "widget.is_action_enabled('export_xlsx') and widget.isExportXlsEnable" msgstr "" #, python-format diff --git a/web_disable_export_group/i18n/web_disable_export_group.pot b/web_disable_export_group/i18n/web_disable_export_group.pot index cb8e38a24..d7ca5b220 100644 --- a/web_disable_export_group/i18n/web_disable_export_group.pot +++ b/web_disable_export_group/i18n/web_disable_export_group.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" +"Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -14,13 +14,13 @@ msgstr "" "Plural-Forms: \n" #. module: web_disable_export_group -#: model:res.groups,name:web_disable_export_group.group_export_xlsx_data -msgid "Direct Export (xlsx)" +#: model:ir.model,name:web_disable_export_group.model_base +msgid "Base" msgstr "" #. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http__display_name -msgid "Display Name" +#: model:res.groups,name:web_disable_export_group.group_export_xlsx_data +msgid "Direct Export (xlsx)" msgstr "" #. module: web_disable_export_group @@ -29,11 +29,8 @@ msgid "HTTP Routing" msgstr "" #. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http__id -msgid "ID" -msgstr "" - -#. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http____last_update -msgid "Last Modified on" +#. openerp-web +#: code:addons/web_disable_export_group/static/src/xml/export_xls_views.xml:0 +#, python-format +msgid "widget.is_action_enabled('export_xlsx') and widget.isExportXlsEnable" msgstr "" diff --git a/web_disable_export_group/i18n/zh_CN.po b/web_disable_export_group/i18n/zh_CN.po index 2fb410734..52029f56c 100644 --- a/web_disable_export_group/i18n/zh_CN.po +++ b/web_disable_export_group/i18n/zh_CN.po @@ -17,13 +17,13 @@ msgstr "" "X-Generator: Weblate 3.8\n" #. module: web_disable_export_group -#: model:res.groups,name:web_disable_export_group.group_export_xlsx_data -msgid "Direct Export (xlsx)" +#: model:ir.model,name:web_disable_export_group.model_base +msgid "Base" msgstr "" #. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http__display_name -msgid "Display Name" +#: model:res.groups,name:web_disable_export_group.group_export_xlsx_data +msgid "Direct Export (xlsx)" msgstr "" #. module: web_disable_export_group @@ -32,13 +32,10 @@ msgid "HTTP Routing" msgstr "HTTP路由" #. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http__id -msgid "ID" -msgstr "" - -#. module: web_disable_export_group -#: model:ir.model.fields,field_description:web_disable_export_group.field_ir_http____last_update -msgid "Last Modified on" +#. openerp-web +#: code:addons/web_disable_export_group/static/src/xml/export_xls_views.xml:0 +#, python-format +msgid "widget.is_action_enabled('export_xlsx') and widget.isExportXlsEnable" msgstr "" #, python-format diff --git a/web_disable_export_group/migrations/14.0.1.1.0/pre-migration.py b/web_disable_export_group/migrations/14.0.1.1.0/pre-migration.py deleted file mode 100644 index 6ba053019..000000000 --- a/web_disable_export_group/migrations/14.0.1.1.0/pre-migration.py +++ /dev/null @@ -1,16 +0,0 @@ -from openupgradelib import openupgrade - - -@openupgrade.migrate() -def migrate(env, version): - # Otherwise, the migration already happened on 13.0 - if not env.ref("web_disable_export_group.group_export_xlsx_data", False): - openupgrade.rename_xmlids( - env.cr, - [ - ( - "web_disable_export_group.group_export_data", - "web_disable_export_group.group_export_xlsx_data", - ) - ], - ) diff --git a/web_disable_export_group/models/__init__.py b/web_disable_export_group/models/__init__.py index 9a5eb7187..ea997b3c5 100644 --- a/web_disable_export_group/models/__init__.py +++ b/web_disable_export_group/models/__init__.py @@ -1 +1,2 @@ from . import ir_http +from . import models diff --git a/web_disable_export_group/models/models.py b/web_disable_export_group/models/models.py new file mode 100644 index 000000000..63a911d91 --- /dev/null +++ b/web_disable_export_group/models/models.py @@ -0,0 +1,23 @@ +# Copyright 2023 Tecnativa - David Vidal +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). +from odoo import models + + +class Base(models.AbstractModel): + _inherit = "base" + + def export_data(self, fields_to_export): + """Export fields for selected objects + + :param fields_to_export: list of fields + :param raw_data: True to return value in native Python type + :rtype: dictionary with a *datas* matrix + + This method is used when exporting data via client menu + """ + if self.env.user.has_group("web_disable_export_group.group_export_xlsx_data"): + fields_to_export = [ + models.fix_import_export_id_paths(f) for f in fields_to_export + ] + return {"datas": self._export_rows(fields_to_export)} + return super().export_data(fields_to_export) diff --git a/web_disable_export_group/readme/CONFIGURE.rst b/web_disable_export_group/readme/CONFIGURE.rst index f32251f68..e1c825c1a 100644 --- a/web_disable_export_group/readme/CONFIGURE.rst +++ b/web_disable_export_group/readme/CONFIGURE.rst @@ -1,2 +1,2 @@ -Enable the group "Direct Export" to the users who are allowed to -make use of the option 'Export xlsx'. +Enable the group *Direct Export* to the users who are allowed to make use of the option +'Export xlsx' from the list view. diff --git a/web_disable_export_group/readme/CONTRIBUTORS.rst b/web_disable_export_group/readme/CONTRIBUTORS.rst index 10aca8773..fa584642e 100644 --- a/web_disable_export_group/readme/CONTRIBUTORS.rst +++ b/web_disable_export_group/readme/CONTRIBUTORS.rst @@ -9,3 +9,4 @@ * João Marques * Alexandre Díaz * Víctor Martínez + * David Vidal diff --git a/web_disable_export_group/readme/DESCRIPTION.rst b/web_disable_export_group/readme/DESCRIPTION.rst index cbe8c22ec..8e9916e39 100644 --- a/web_disable_export_group/readme/DESCRIPTION.rst +++ b/web_disable_export_group/readme/DESCRIPTION.rst @@ -1,5 +1,7 @@ -The standard export group prevents both options: 'Direct Export (xlsx)' and 'Export All'. +The standard grants/prevents access to any UI export via *Access to export feature* +group. -This module adds a new group for the 'Direct Export (xlsx)' feature, leaving the standard one for only the 'Export All' feature. +This module adds a new group for the 'Direct Export (xlsx)' feature, leaving the +standard one for only the 'Export All' feature. -Admin user can always use the export option. +Admin users can always use the export option. diff --git a/web_disable_export_group/readme/USAGE.rst b/web_disable_export_group/readme/USAGE.rst index 58da01296..e35c9bd40 100644 --- a/web_disable_export_group/readme/USAGE.rst +++ b/web_disable_export_group/readme/USAGE.rst @@ -1 +1,3 @@ -Every user without *Direct Export (xlsx)* permission won't have the option available. +- Users in the *Access to export feature* group or admins can export in any way. +- Users in the *Direct Export (xlsx)* group can only use the default export feature + from the list view. diff --git a/web_disable_export_group/security/groups.xml b/web_disable_export_group/security/groups.xml index 3eb23a749..cdcf4e0e7 100644 --- a/web_disable_export_group/security/groups.xml +++ b/web_disable_export_group/security/groups.xml @@ -4,11 +4,16 @@ Direct Export (xlsx) - + + + diff --git a/web_disable_export_group/security/ir.model.access.csv b/web_disable_export_group/security/ir.model.access.csv new file mode 100644 index 000000000..589bcc421 --- /dev/null +++ b/web_disable_export_group/security/ir.model.access.csv @@ -0,0 +1,2 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_ir_exports_group_xls","ir_exports group_xls","base.model_ir_exports","web_disable_export_group.group_export_xlsx_data",1,0,0,0 diff --git a/web_disable_export_group/static/description/index.html b/web_disable_export_group/static/description/index.html index a0f9833a4..3f93df52b 100644 --- a/web_disable_export_group/static/description/index.html +++ b/web_disable_export_group/static/description/index.html @@ -1,20 +1,20 @@ - + - + Web Disable Export Group