diff --git a/web_export_view/README.rst b/web_export_view/README.rst new file mode 100644 index 00000000..e9872121 --- /dev/null +++ b/web_export_view/README.rst @@ -0,0 +1,122 @@ +======================= +Web Export Current View +======================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/12.0/web_export_view + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_export_view + :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/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +One of the best Odoo's features is exporting custom data to CSV/XLS. You can +do it by clicking on the export link in the sidebar. The export action allows +us to configure what to be exported by selecting fields, etc, and allows you +to save your export as a template so that you can export it once again without +having to configure it again. + +That feature is as great and advanced as limited for an everyday experience. +A lot of customers want simply to export the tree view they are looking to. + +If you miss this feature as us, probably you'll find an answer into our +web_export_view module. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +If we wanted to disallow users to use the features provided by this module, we +can add them to the group *Disallow Export View Data to Excel*. + +Usage +===== + +After you installed it, you'll find an additional link 'Export current view' +right on the sidebar. By clicking on it you'll get a XLS file contains +the same data of the tree view you are looking at, headers included. + +Known issues / Roadmap +====================== + +Pedro M. Baeza (pedro.baeza@tecnativa.com): +When you have groups, they are not exported to Excel. It would be desirable to have this option. +One of the problems with this module is that you can't export data from a view with mode="tree". +Changing the approach to have the button always visible (we should relocate it also to another place, +as the current location is not visible for these views), and digging correctly in the DOM elements +for this view (very similar to the normal tree view one) will do the trick. This will also help users +to locate the feature, as it's hidden now by default and users don't think about selecting records. +The behavior will be: nothing selected > you export all (including groups). +Something or all selected: export the selection. + +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 +~~~~~~~ + +* Henry Zhou +* Agile Business Group + +Contributors +~~~~~~~~~~~~ + +* Henry Zhou (MAXodoo) +* Rodney +* Simone Orsi +* Lorenzo Battistini +* Stefan Rijnhart +* Leonardo Pistone +* Jose Maria Bernet +* Alexandre Díaz +* Valtteri Lattu +* `Tecnativa `_: + + * David Vidal + * Ernesto Tejeda + +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_export_view/__init__.py b/web_export_view/__init__.py new file mode 100644 index 00000000..e046e49f --- /dev/null +++ b/web_export_view/__init__.py @@ -0,0 +1 @@ +from . import controllers diff --git a/web_export_view/__manifest__.py b/web_export_view/__manifest__.py new file mode 100644 index 00000000..bd86c043 --- /dev/null +++ b/web_export_view/__manifest__.py @@ -0,0 +1,30 @@ +# Copyright 2012 Agile Business Group +# Copyright 2012 Domsense srl () +# Copyright 2012 Therp BV +# Copyright 2016 Henry Zhou (http://www.maxodoo.com) +# Copyright 2016 Rodney (http://clearcorp.cr/) +# Copyright 2019 Tecnativa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + 'name': 'Web Export Current View', + 'version': '12.0.1.0.0', + 'category': 'Web', + 'author': 'Henry Zhou, Agile Business Group, \ + Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/web', + 'license': 'AGPL-3', + 'depends': [ + 'web', + ], + "data": [ + 'security/groups.xml', + 'views/web_export_view_view.xml', + ], + 'qweb': [ + "static/src/xml/web_export_view_template.xml", + ], + + 'installable': True, + 'auto_install': False, +} diff --git a/web_export_view/controllers/__init__.py b/web_export_view/controllers/__init__.py new file mode 100644 index 00000000..e046e49f --- /dev/null +++ b/web_export_view/controllers/__init__.py @@ -0,0 +1 @@ +from . import controllers diff --git a/web_export_view/controllers/controllers.py b/web_export_view/controllers/controllers.py new file mode 100644 index 00000000..fed05996 --- /dev/null +++ b/web_export_view/controllers/controllers.py @@ -0,0 +1,34 @@ +# Copyright 2016 Henry Zhou (http://www.maxodoo.com) +# Copyright 2016 Rodney (http://clearcorp.cr/) +# Copyright 2012 Agile Business Group +# Copyright 2012 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import json +import odoo.http as http +from odoo.http import request +from odoo.addons.web.controllers.main import ExcelExport + + +class ExcelExportView(ExcelExport): + def __getattribute__(self, name): + if name == 'fmt': + raise AttributeError() + return super(ExcelExportView, self).__getattribute__(name) + + @http.route('/web/export/xls_view', type='http', auth='user') + def export_xls_view(self, data, token): + data = json.loads(data) + model = data.get('model', []) + columns_headers = data.get('headers', []) + rows = data.get('rows', []) + + return request.make_response( + self.from_data(columns_headers, rows), + headers=[ + ('Content-Disposition', 'attachment; filename="%s"' + % self.filename(model)), + ('Content-Type', self.content_type) + ], + cookies={'fileToken': token} + ) diff --git a/web_export_view/i18n/da.po b/web_export_view/i18n/da.po new file mode 100644 index 00000000..b29f4cbf --- /dev/null +++ b/web_export_view/i18n/da.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_export_view +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: da\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" + +#. module: web_export_view +#: model:res.groups,name:web_export_view.group_disallow_export_view_data_excel +msgid "Disallow Export View Data to Excel" +msgstr "" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/xml/web_export_view_template.xml:6 +#, python-format +msgid "Export xls" +msgstr "" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "False" +msgstr "" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "True" +msgstr "" diff --git a/web_export_view/i18n/de.po b/web_export_view/i18n/de.po new file mode 100644 index 00000000..f802b201 --- /dev/null +++ b/web_export_view/i18n/de.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_export_view +# +# Translators: +# Niki Waibel , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-28 18:03+0000\n" +"PO-Revision-Date: 2017-04-28 18:03+0000\n" +"Last-Translator: Niki Waibel , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\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" + +#. module: web_export_view +#: model:res.groups,name:web_export_view.group_disallow_export_view_data_excel +msgid "Disallow Export View Data to Excel" +msgstr "" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/xml/web_export_view_template.xml:6 +#, python-format +msgid "Export xls" +msgstr "Exportiere xls" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "False" +msgstr "Falsch" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "True" +msgstr "Richtig" diff --git a/web_export_view/i18n/es.po b/web_export_view/i18n/es.po new file mode 100644 index 00000000..d05b0ef4 --- /dev/null +++ b/web_export_view/i18n/es.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_export_view +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-28 18:03+0000\n" +"PO-Revision-Date: 2017-04-28 18:03+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\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" + +#. module: web_export_view +#: model:res.groups,name:web_export_view.group_disallow_export_view_data_excel +msgid "Disallow Export View Data to Excel" +msgstr "" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/xml/web_export_view_template.xml:6 +#, python-format +msgid "Export xls" +msgstr "Exportar XLS" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "False" +msgstr "Falso" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "True" +msgstr "Verdadero" diff --git a/web_export_view/i18n/hr.po b/web_export_view/i18n/hr.po new file mode 100644 index 00000000..46301112 --- /dev/null +++ b/web_export_view/i18n/hr.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_export_view +# +# Translators: +# Bole , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-28 18:03+0000\n" +"PO-Revision-Date: 2017-04-28 18:03+0000\n" +"Last-Translator: Bole , 2017\n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\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" + +#. module: web_export_view +#: model:res.groups,name:web_export_view.group_disallow_export_view_data_excel +msgid "Disallow Export View Data to Excel" +msgstr "" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/xml/web_export_view_template.xml:6 +#, python-format +msgid "Export xls" +msgstr "Izvoz u XLS" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "False" +msgstr "NE" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "True" +msgstr "DA" diff --git a/web_export_view/i18n/nl_NL.po b/web_export_view/i18n/nl_NL.po new file mode 100644 index 00000000..719c5d80 --- /dev/null +++ b/web_export_view/i18n/nl_NL.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_export_view +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-01 03:34+0000\n" +"PO-Revision-Date: 2017-07-01 03:34+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" +"Language: nl_NL\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" + +#. module: web_export_view +#: model:res.groups,name:web_export_view.group_disallow_export_view_data_excel +msgid "Disallow Export View Data to Excel" +msgstr "" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/xml/web_export_view_template.xml:6 +#, python-format +msgid "Export xls" +msgstr "Exporteer xls" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "False" +msgstr "Fout" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "True" +msgstr "Waar" diff --git a/web_export_view/i18n/pt_BR.po b/web_export_view/i18n/pt_BR.po new file mode 100644 index 00000000..cfe2c992 --- /dev/null +++ b/web_export_view/i18n/pt_BR.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_export_view +# +# Translators: +# Rodrigo de Almeida Sottomaior Macedo , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-22 08:26+0000\n" +"PO-Revision-Date: 2017-06-22 08:26+0000\n" +"Last-Translator: Rodrigo de Almeida Sottomaior Macedo " +", 2017\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" +"teams/23907/pt_BR/)\n" +"Language: pt_BR\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" + +#. module: web_export_view +#: model:res.groups,name:web_export_view.group_disallow_export_view_data_excel +msgid "Disallow Export View Data to Excel" +msgstr "" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/xml/web_export_view_template.xml:6 +#, python-format +msgid "Export xls" +msgstr "Exportar xls" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "False" +msgstr "Falso" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "True" +msgstr "Verdadeiro" diff --git a/web_export_view/i18n/web_export_view.pot b/web_export_view/i18n/web_export_view.pot new file mode 100644 index 00000000..b626484a --- /dev/null +++ b/web_export_view/i18n/web_export_view.pot @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_export_view +# +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_export_view +#: model:res.groups,name:web_export_view.group_disallow_export_view_data_excel +msgid "Disallow Export View Data to Excel" +msgstr "" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/xml/web_export_view_template.xml:6 +#, python-format +msgid "Export xls" +msgstr "" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "False" +msgstr "" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "True" +msgstr "" + diff --git a/web_export_view/i18n/zh_CN.po b/web_export_view/i18n/zh_CN.po new file mode 100644 index 00000000..ebf289c9 --- /dev/null +++ b/web_export_view/i18n/zh_CN.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_export_view +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-28 18:03+0000\n" +"PO-Revision-Date: 2017-04-28 18:03+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Chinese (China) (https://www.transifex.com/oca/teams/23907/" +"zh_CN/)\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" + +#. module: web_export_view +#: model:res.groups,name:web_export_view.group_disallow_export_view_data_excel +msgid "Disallow Export View Data to Excel" +msgstr "" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/xml/web_export_view_template.xml:6 +#, python-format +msgid "Export xls" +msgstr "导出 xls" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "False" +msgstr "否" + +#. module: web_export_view +#. openerp-web +#: code:addons/web_export_view/static/src/js/web_export_view.js:90 +#, python-format +msgid "True" +msgstr "是" diff --git a/web_export_view/readme/CONFIGURATION.rst b/web_export_view/readme/CONFIGURATION.rst new file mode 100644 index 00000000..3ae2e649 --- /dev/null +++ b/web_export_view/readme/CONFIGURATION.rst @@ -0,0 +1,2 @@ +If we wanted to disallow users to use the features provided by this module, we +can add them to the group *Disallow Export View Data to Excel*. \ No newline at end of file diff --git a/web_export_view/readme/CONFIGURE.rst b/web_export_view/readme/CONFIGURE.rst new file mode 100644 index 00000000..3ae2e649 --- /dev/null +++ b/web_export_view/readme/CONFIGURE.rst @@ -0,0 +1,2 @@ +If we wanted to disallow users to use the features provided by this module, we +can add them to the group *Disallow Export View Data to Excel*. \ No newline at end of file diff --git a/web_export_view/readme/CONTRIBUTORS.rst b/web_export_view/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..3b71ec42 --- /dev/null +++ b/web_export_view/readme/CONTRIBUTORS.rst @@ -0,0 +1,13 @@ +* Henry Zhou (MAXodoo) +* Rodney +* Simone Orsi +* Lorenzo Battistini +* Stefan Rijnhart +* Leonardo Pistone +* Jose Maria Bernet +* Alexandre Díaz +* Valtteri Lattu +* `Tecnativa `_: + + * David Vidal + * Ernesto Tejeda diff --git a/web_export_view/readme/DESCRIPTION.rst b/web_export_view/readme/DESCRIPTION.rst new file mode 100644 index 00000000..3cd7aa3e --- /dev/null +++ b/web_export_view/readme/DESCRIPTION.rst @@ -0,0 +1,11 @@ +One of the best Odoo's features is exporting custom data to CSV/XLS. You can +do it by clicking on the export link in the sidebar. The export action allows +us to configure what to be exported by selecting fields, etc, and allows you +to save your export as a template so that you can export it once again without +having to configure it again. + +That feature is as great and advanced as limited for an everyday experience. +A lot of customers want simply to export the tree view they are looking to. + +If you miss this feature as us, probably you'll find an answer into our +web_export_view module. diff --git a/web_export_view/readme/ROADMAP.rst b/web_export_view/readme/ROADMAP.rst new file mode 100644 index 00000000..05d17110 --- /dev/null +++ b/web_export_view/readme/ROADMAP.rst @@ -0,0 +1,9 @@ +Pedro M. Baeza (pedro.baeza@tecnativa.com): +When you have groups, they are not exported to Excel. It would be desirable to have this option. +One of the problems with this module is that you can't export data from a view with mode="tree". +Changing the approach to have the button always visible (we should relocate it also to another place, +as the current location is not visible for these views), and digging correctly in the DOM elements +for this view (very similar to the normal tree view one) will do the trick. This will also help users +to locate the feature, as it's hidden now by default and users don't think about selecting records. +The behavior will be: nothing selected > you export all (including groups). +Something or all selected: export the selection. diff --git a/web_export_view/readme/USAGE.rst b/web_export_view/readme/USAGE.rst new file mode 100644 index 00000000..45613441 --- /dev/null +++ b/web_export_view/readme/USAGE.rst @@ -0,0 +1,3 @@ +After you installed it, you'll find an additional link 'Export current view' +right on the sidebar. By clicking on it you'll get a XLS file contains +the same data of the tree view you are looking at, headers included. diff --git a/web_export_view/security/groups.xml b/web_export_view/security/groups.xml new file mode 100644 index 00000000..95ad71ed --- /dev/null +++ b/web_export_view/security/groups.xml @@ -0,0 +1,9 @@ + + + + + Disallow Export View Data to Excel + + + + diff --git a/web_export_view/static/description/icon.png b/web_export_view/static/description/icon.png new file mode 100644 index 00000000..1b1b0d1e Binary files /dev/null and b/web_export_view/static/description/icon.png differ diff --git a/web_export_view/static/description/index.html b/web_export_view/static/description/index.html new file mode 100644 index 00000000..e823ea02 --- /dev/null +++ b/web_export_view/static/description/index.html @@ -0,0 +1,653 @@ + + + + + + + Web Export Current View + + + +
+

Web Export Current View

+ + +

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

+

One of the best Odoo’s features is exporting custom data to CSV/XLS. You + can + do it by clicking on the export link in the sidebar. The export action + allows + us to configure what to be exported by selecting fields, etc, and + allows you + to save your export as a template so that you can export it once again + without + having to configure it again.

+

That feature is as great and advanced as limited for an everyday + experience. + A lot of customers want simply to export the tree view they are looking + to.

+

If you miss this feature as us, probably you’ll find an answer into our + web_export_view module.

+

Table of contents

+ +
+

Configuration

+

If we wanted to disallow users to use the features provided by this + module, we + can add them to the group Disallow Export View Data to + Excel.

+
+
+

Usage

+

After you installed it, you’ll find an additional link ‘Export + current view’ + right on the sidebar. By clicking on it you’ll get a XLS file + contains + the same data of the tree view you are looking at, headers + included.

+
+
+

Known issues / Roadmap

+

Pedro M. Baeza (pedro.baeza@tecnativa.com): + When you have groups, they are not exported to Excel. It would be + desirable to have this option. + One of the problems with this module is that you can’t export data + from a view with mode=”tree”. + Changing the approach to have the button always visible (we should + relocate it also to another place, + as the current location is not visible for these views), and + digging correctly in the DOM elements + for this view (very similar to the normal tree view one) will do + the trick. This will also help users + to locate the feature, as it’s hidden now by default and users + don’t think about selecting records. + The behavior will be: nothing selected > you export all + (including groups). + Something or all selected: export the selection.

+
+
+

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

+
    +
  • Henry Zhou
  • +
  • Agile Business Group
  • +
+
+
+

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_export_view/static/src/js/web_export_view.js b/web_export_view/static/src/js/web_export_view.js new file mode 100644 index 00000000..71cc034f --- /dev/null +++ b/web_export_view/static/src/js/web_export_view.js @@ -0,0 +1,133 @@ +odoo.define('web_export_view', function (require) { + "use strict"; + + var core = require('web.core'); + var Sidebar = require('web.Sidebar'); + var session = require('web.session'); + var crash_manager = require('web.crash_manager'); + + var QWeb = core.qweb; + + var _t = core._t; + + Sidebar.include({ + + _redraw: function () { + var self = this; + this._super.apply(this, arguments); + if (self.getParent().renderer.viewType === 'list') { + session.user_has_group( + 'web_export_view.group_disallow_export_view_data_excel') + .then(function (has_group) { + var export_btn = self.$el.find('.export_treeview_xls'); + if (!has_group && !export_btn.length) { + self.$el.find('.o_dropdown') + .parent().append(QWeb.render( + 'WebExportTreeViewXls', {widget: self})); + self.$el.find('.export_treeview_xls').on('click', + self.on_sidebar_export_treeview_xls); + } + }); + } + }, + + on_sidebar_export_treeview_xls: function () { + // Select the first list of the current (form) view + // or assume the main view is a list view and use that + var view = this.getParent(), + children = view.getChildren(); + var c = crash_manager; + + if (children) { + children.every(function (child) { + if (child.field && child.field.type === 'one2many') { + view = child.viewmanager.views.list.controller; + return false; + } + if (child.field && child.field.type === 'many2many') { + view = child.list_view; + return false; + } + return true; + }); + } + var export_columns_keys = []; + var export_columns_names = []; + var column_index = 0; + var column_header_selector = ''; + $.each(view.renderer.columns, function () { + if (this.tag === 'field' && + (this.attrs.widget === undefined || + this.attrs.widget !== 'handle')) { + export_columns_keys.push(column_index); + column_header_selector = '.o_list_view > thead > tr> ' + + 'th:not([class*="o_list_record_selector"]):eq(' + + column_index + ')'; + export_columns_names.push( + view.$el.find(column_header_selector)[0].textContent); + } + ++column_index; + }); + var export_rows = []; + $.blockUI(); + if (children) { + // Find only rows with data + view.$el.find('.o_list_view > tbody > tr.o_data_row:' + + 'has(.o_list_record_selector input:checkbox:checked)') + .each(function () { + var $row = $(this); + var export_row = []; + $.each(export_columns_keys, function () { + var $cell = $row.find( + 'td.o_data_cell:eq('+this+')'); + var $cellcheckbox = $cell.find( + '.o_checkbox input:checkbox'); + if ($cellcheckbox.length) { + export_row.push( + $cellcheckbox.is(":checked") + ? _t("True") : _t("False") + ); + } else { + var text = $cell.text().trim(); + var is_number = + $cell.hasClass('o_list_number') && + !$cell.hasClass('o_float_time_cell'); + if (is_number) { + var db_params = _t.database.parameters; + export_row.push(parseFloat( + text + // Remove thousands separator + .split(db_params.thousands_sep) + .join("") + // Always use a `.` as decimal + // separator + .replace(db_params.decimal_point, + ".") + // Remove non-numeric characters + .replace(/[^\d.-]/g, "") + )); + } else { + export_row.push(text); + } + } + }); + export_rows.push(export_row); + }); + } + + session.get_file({ + url: '/web/export/xls_view', + data: { + data: JSON.stringify({ + model: view.modelName, + headers: export_columns_names, + rows: export_rows, + }), + }, + complete: $.unblockUI, + error: c.rpc_error.bind(c), + }); + }, + + }); +}); diff --git a/web_export_view/static/src/xml/web_export_view_template.xml b/web_export_view/static/src/xml/web_export_view_template.xml new file mode 100644 index 00000000..32bd002e --- /dev/null +++ b/web_export_view/static/src/xml/web_export_view_template.xml @@ -0,0 +1,11 @@ + + + + +
+ +
+
+
diff --git a/web_export_view/views/web_export_view_view.xml b/web_export_view/views/web_export_view_view.xml new file mode 100644 index 00000000..4787238e --- /dev/null +++ b/web_export_view/views/web_export_view_view.xml @@ -0,0 +1,9 @@ + + + + +