Browse Source

[MIG 10.0] web_export_view (#444)

pull/1269/head
Henry Zhou 8 years ago
committed by ernesto
parent
commit
4935fab727
  1. 28
      web_export_view/README.rst
  2. 20
      web_export_view/__init__.py
  3. 28
      web_export_view/__manifest__.py
  4. 41
      web_export_view/__openerp__.py
  5. 20
      web_export_view/controllers/__init__.py
  6. 36
      web_export_view/controllers/controllers.py
  7. 44
      web_export_view/i18n/de.po
  8. 46
      web_export_view/i18n/es.po
  9. 44
      web_export_view/i18n/fr.po
  10. 46
      web_export_view/i18n/is.po
  11. 44
      web_export_view/i18n/nl.po
  12. 47
      web_export_view/i18n/sl.po
  13. 43
      web_export_view/i18n/web_export_view.pot
  14. 38
      web_export_view/i18n/zh_CN.po
  15. 99
      web_export_view/static/src/js/web_export_view.js
  16. 13
      web_export_view/static/src/xml/web_export_view_template.xml
  17. 11
      web_export_view/view/web_export_view.xml
  18. 9
      web_export_view/views/web_export_view_view.xml

28
web_export_view/README.rst

@ -4,7 +4,7 @@
Export Current View Export Current View
=================== ===================
One of the best OpenERP's features is exporting custom data to CSV/XLS. You can
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 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 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 to save your export as a template so that you can export it once again without
@ -21,19 +21,31 @@ Usage
===== =====
After you installed it, you'll find an additional link 'Export current view' After you installed it, you'll find an additional link 'Export current view'
right below the 'Export' one. By clicking on it you'll get a XLS file contains
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. the same data of the tree view you are looking at, headers included.
Known Issues
============
Pedro M. Baeza (pedro.baeza@gmail.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 Bug Tracker
=========== ===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/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
`here <https://github.com/OCA/web/issues/new?body=module:%20web_export_view%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/web/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.
Credits Credits
======= =======
@ -41,6 +53,8 @@ Credits
Contributors Contributors
------------ ------------
* Henry Zhou (MAXodoo) <zhouhenry@live.com>
* Rodney <https://github.com/rv-clearcorp>
* Simone Orsi <simahawk@gmail.com> * Simone Orsi <simahawk@gmail.com>
* Lorenzo Battistini <lorenzo.battistini@agilebg.com> * Lorenzo Battistini <lorenzo.battistini@agilebg.com>
* Stefan Rijnhart <stefan@therp.nl> * Stefan Rijnhart <stefan@therp.nl>

20
web_export_view/__init__.py

@ -1,21 +1,3 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import controllers from . import controllers

28
web_export_view/__manifest__.py

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Henry Zhou (http://www.maxodoo.com)
# Copyright 2016 Rodney (http://clearcorp.cr/)
# Copyright 2012 Agile Business Group
# Copyright 2012 Domsense srl (<http://www.domsense.com>)
# Copyright 2012 Therp BV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Web Export Current View',
'version': '10.0.1.0.0',
'category': 'Web',
'author': 'Henry Zhou, Agile Business Group, \
Odoo Community Association (OCA)',
'website': 'http://www.agilebg.com',
'license': 'AGPL-3',
'depends': [
'web',
],
"data": [
'views/web_export_view_view.xml',
],
'qweb': [
"static/src/xml/web_export_view_template.xml",
],
'installable': True,
'auto_install': False,
}

41
web_export_view/__openerp__.py

@ -1,41 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Export Current View',
'version': '8.0.1.2.0',
'category': 'Web',
'author': "Agile Business Group,Odoo Community Association (OCA)",
'website': 'http://www.agilebg.com',
'license': 'AGPL-3',
'depends': [
'web',
],
'data': [
'view/web_export_view.xml',
],
'qweb': [
'static/src/xml/web_export_view_template.xml',
],
'installable': True,
'auto_install': False,
'web_preload': False,
}

20
web_export_view/controllers/__init__.py

@ -1,21 +1,3 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import controllers from . import controllers

36
web_export_view/controllers/controllers.py

@ -1,32 +1,14 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
# Copyright (C) 2012-2013:
# Agile Business Group sagl (<http://www.agilebg.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
try:
import json
except ImportError:
import simplejson as json
# 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 openerp.http as http
from openerp.http import request
from openerp.addons.web.controllers.main import ExcelExport
import json
import odoo.http as http
from odoo.http import request
from odoo.addons.web.controllers.main import ExcelExport
class ExcelExportView(ExcelExport): class ExcelExportView(ExcelExport):

44
web_export_view/i18n/de.po

@ -1,44 +0,0 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-10-21 11:59+0000\n"
"PO-Revision-Date: 2013-12-07 17:21+0000\n"
"Last-Translator: Nicolas JEUDY <njeudy@tuxservices.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-06-28 06:02+0000\n"
"X-Generator: Launchpad (build 17077)\n"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:7
#, python-format
msgid "Export Current View"
msgstr "Aktuelle Liste exportieren"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:9
#, python-format
msgid "Excel"
msgstr "Excel"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:81
#, python-format
msgid "True"
msgstr ""
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:84
#, python-format
msgid "False"
msgstr ""

46
web_export_view/i18n/es.po

@ -1,46 +0,0 @@
# Spanish translation for web-addons
# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014
# This file is distributed under the same license as the web-addons package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: web-addons\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2013-10-21 11:59+0000\n"
"PO-Revision-Date: 2014-02-20 23:18+0000\n"
"Last-Translator: Pedro Manuel Baeza <pedro.baeza@gmail.com>\n"
"Language-Team: Spanish <es@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-06-28 06:02+0000\n"
"X-Generator: Launchpad (build 17077)\n"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:7
#, python-format
msgid "Export Current View"
msgstr "Exportar vista actual"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:9
#, python-format
msgid "Excel"
msgstr "Excel"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:81
#, python-format
msgid "True"
msgstr "Verdadero"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:84
#, python-format
msgid "False"
msgstr "Falso"

44
web_export_view/i18n/fr.po

@ -1,44 +0,0 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-10-21 11:59+0000\n"
"PO-Revision-Date: 2014-03-13 09:06+0000\n"
"Last-Translator: Sylvain LE GAL (GRAP) <Unknown>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-06-28 06:02+0000\n"
"X-Generator: Launchpad (build 17077)\n"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:7
#, python-format
msgid "Export Current View"
msgstr "Exporter la vue courante"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:9
#, python-format
msgid "Excel"
msgstr "Excel"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:81
#, python-format
msgid "True"
msgstr ""
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:84
#, python-format
msgid "False"
msgstr ""

46
web_export_view/i18n/is.po

@ -1,46 +0,0 @@
# Icelandic translation for web-addons
# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014
# This file is distributed under the same license as the web-addons package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: web-addons\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2013-10-21 11:59+0000\n"
"PO-Revision-Date: 2014-04-11 08:56+0000\n"
"Last-Translator: Sveinn í Felli <sv1@fellsnet.is>\n"
"Language-Team: Icelandic <is@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-06-28 06:02+0000\n"
"X-Generator: Launchpad (build 17077)\n"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:7
#, python-format
msgid "Export Current View"
msgstr "Flytja út núverandi sýn"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:9
#, python-format
msgid "Excel"
msgstr "Excel"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:81
#, python-format
msgid "True"
msgstr ""
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:84
#, python-format
msgid "False"
msgstr ""

44
web_export_view/i18n/nl.po

@ -1,44 +0,0 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-10-21 11:59+0000\n"
"PO-Revision-Date: 2013-12-07 17:21+0000\n"
"Last-Translator: Nicolas JEUDY <njeudy@tuxservices.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-06-28 06:02+0000\n"
"X-Generator: Launchpad (build 17077)\n"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:7
#, python-format
msgid "Export Current View"
msgstr "Huidige lijst exporteren"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:9
#, python-format
msgid "Excel"
msgstr "Excel"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:81
#, python-format
msgid "True"
msgstr ""
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:84
#, python-format
msgid "False"
msgstr ""

47
web_export_view/i18n/sl.po

@ -1,47 +0,0 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
#
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015.
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-10-21 11:59+0000\n"
"PO-Revision-Date: 2015-04-24 08:07+0100\n"
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
"Language-Team: Slovenian <translate@matmoz.si>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
"Language: sl\n"
"X-Generator: Lokalize 2.0\n"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:7
#, python-format
msgid "Export Current View"
msgstr "Izvoz trenutnega pogleda"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:9
#, python-format
msgid "Excel"
msgstr "Excel"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:81
#, python-format
msgid "True"
msgstr "Pravilno"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:84
#, python-format
msgid "False"
msgstr "Nepravilno"

43
web_export_view/i18n/web_export_view.pot

@ -1,43 +0,0 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-10-21 11:59+0000\n"
"PO-Revision-Date: 2013-10-21 11:59+0000\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
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:7
#, python-format
msgid "Export Current View"
msgstr ""
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/xml/web_advanced_export.xml:9
#, python-format
msgid "Excel"
msgstr ""
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:81
#, python-format
msgid "True"
msgstr ""
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_advanced_export.js:84
#, python-format
msgid "False"
msgstr ""

38
web_export_view/i18n/zh_CN.po

@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_export_view
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-11-04 02:11+0000\n"
"PO-Revision-Date: 2016-11-04 02:11+0000\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
#. 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:66
#, python-format
msgid "False"
msgstr "否"
#. module: web_export_view
#. openerp-web
#: code:addons/web_export_view/static/src/js/web_export_view.js:63
#, python-format
msgid "True"
msgstr "是"

99
web_export_view/static/src/js/web_export_view.js

@ -1,38 +1,24 @@
// @@@ web_export_view custom JS @@@
//#############################################################################
//
// Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
// Copyright (C) 2012 Therp BV (<http://therp.nl>)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//#############################################################################
openerp.web_export_view = function (instance) {
odoo.define('web_export_view', function (require) {
"use strict";
var _t = instance.web._t, QWeb = instance.web.qweb;
var core = require('web.core');
var Sidebar = require('web.Sidebar');
var QWeb = core.qweb;
var _t = core._t;
Sidebar.include({
instance.web.Sidebar.include({
redraw: function () { redraw: function () {
var self = this; var self = this;
this._super.apply(this, arguments); this._super.apply(this, arguments);
if (self.getParent().ViewManager.active_view == 'list') {
self.$el.find('.oe_sidebar').append(QWeb.render('AddExportViewMain', {widget: self}));
self.$el.find('.oe_sidebar_export_view_xls').on('click', self.on_sidebar_export_view_xls);
if (self.getParent().ViewManager.active_view.type == 'list') {
self.$el.find('.o_dropdown').last().append(QWeb.render('WebExportTreeViewXls', {widget: self}));
self.$el.find('.export_treeview_xls').on('click', self.on_sidebar_export_treeview_xls);
} }
}, },
on_sidebar_export_view_xls: function () {
on_sidebar_export_treeview_xls: function () {
// Select the first list of the current (form) view // Select the first list of the current (form) view
// or assume the main view is a list view and use that // or assume the main view is a list view and use that
var self = this, var self = this,
@ -51,50 +37,51 @@ openerp.web_export_view = function (instance) {
return true; return true;
}); });
} }
export_columns_keys = [];
export_columns_names = [];
var export_columns_keys = [];
var export_columns_names = [];
$.each(view.visible_columns, function () { $.each(view.visible_columns, function () {
if (this.tag == 'field') {
if (this.tag == 'field' && (this.widget === undefined || this.widget != 'handle')) {
// non-fields like `_group` or buttons // non-fields like `_group` or buttons
export_columns_keys.push(this.id); export_columns_keys.push(this.id);
export_columns_names.push(this.string); export_columns_names.push(this.string);
} }
}); });
rows = view.$el.find('.oe_list_content > tbody > tr');
export_rows = [];
var rows = view.$el.find('.o_list_view > tbody > tr');
var export_rows = [];
$.each(rows, function () { $.each(rows, function () {
$row = $(this);
var $row = $(this);
// find only rows with data // find only rows with data
if ($row.attr('data-id')) { if ($row.attr('data-id')) {
export_row = [];
checked = $row.find('th input[type=checkbox]').attr("checked");
if (children && checked === "checked") {
var export_row = [];
var checked = $row.find('.o_list_record_selector input[type=checkbox]').is(':checked');
if (children && checked === true) {
$.each(export_columns_keys, function () { $.each(export_columns_keys, function () {
cell = $row.find('td[data-field="' + this + '"]').get(0);
text = cell.text || cell.textContent || cell.innerHTML || "";
if (cell.classList.contains("oe_list_field_float")) {
export_row.push(instance.web.parse_value(text, {'type': "float"}));
}
else if (cell.classList.contains("oe_list_field_boolean")) {
var data_id = $('<div>' + cell.innerHTML + '</div>');
if (data_id.find('input').get(0).checked) {
var $cell = $row.find('td[data-field="' + this + '"]')
var $cellcheckbox = $cell.find('.o_checkbox input[type=checkbox]');
if ($cellcheckbox.length) {
if ($cellcheckbox.is(':checked')) {
export_row.push(_t("True")); export_row.push(_t("True"));
} }
else { else {
export_row.push(_t("False")); export_row.push(_t("False"));
} }
} }
else if (cell.classList.contains("oe_list_field_integer")) {
var tmp2 = text;
do {
tmp = tmp2;
tmp2 = tmp.replace(instance.web._t.database.parameters.thousands_sep, "");
} while (tmp !== tmp2);
export_row.push(parseInt(tmp2));
}
else { else {
export_row.push(text.trim());
var cell = $cell.get(0);
var text = cell.text || cell.textContent || cell.innerHTML || "";
if (cell.classList.contains("o_list_number")) {
var tmp2 = text;
do {
var tmp = tmp2;
tmp2 = tmp.replace(_t.database.parameters.thousands_sep, "");
} while (tmp !== tmp2);
tmp2 = tmp.replace(_t.database.parameters.decimal_point, ".");
export_row.push(parseFloat(tmp2));
}
else {
export_row.push(text.trim());
}
} }
}); });
export_rows.push(export_row); export_rows.push(export_row);
@ -112,6 +99,6 @@ openerp.web_export_view = function (instance) {
complete: $.unblockUI complete: $.unblockUI
}); });
} }
});
};
});
});

13
web_export_view/static/src/xml/web_export_view_template.xml

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve"> <templates id="template" xml:space="preserve">
<t t-name="AddExportViewMain">
<div class="oe_form_dropdown_section">
<button class="oe_dropdown_toggle oe_dropdown_arrow">Export Current View</button>
<ul class="oe_dropdown_menu">
<li class="oe_sidebar_export_view_xls"><span>Excel</span></li>
</ul>
<t t-name="WebExportTreeViewXls">
<div class="o_cp_sidebar btn-group btn-group-sm">
<button class="btn btn-default export_treeview_xls" type="button" title="Export xls">
<i t-translation="off" class="fa fa-file-excel-o"></i>
</button>
</div> </div>
</t> </t>
</templates>
</templates>

11
web_export_view/view/web_export_view.xml

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="assets_backend" name="web_export_view assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/web_export_view/static/src/js/web_export_view.js"></script>
</xpath>
</template>
</data>
</openerp>

9
web_export_view/views/web_export_view_view.xml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_backend" name="web_export_view assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/web_export_view/static/src/js/web_export_view.js"></script>
</xpath>
</template>
</odoo>
Loading…
Cancel
Save