diff --git a/web_export_view/README.rst b/web_export_view/README.rst index 6a0ccb67..63fa1bf2 100644 --- a/web_export_view/README.rst +++ b/web_export_view/README.rst @@ -34,6 +34,12 @@ 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 `_. +Known Issues +============ + +Enterprise version limitation: exported values are interpreted always as strings +so if you want to create formulas or calculations on top of them +you need to convert them manually. Credits ======= @@ -41,10 +47,11 @@ Credits Contributors ------------ - * Simone Orsi + * Simone Orsi * Lorenzo Battistini * Stefan Rijnhart * Leonardo Pistone + * Rodney Vargas Maintainer ---------- diff --git a/web_export_view/__init__.py b/web_export_view/__init__.py index 9a651413..0e4e530c 100644 --- a/web_export_view/__init__.py +++ b/web_export_view/__init__.py @@ -1,21 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2012 Agile Business Group sagl () -# Copyright (C) 2012 Domsense srl () -# -# 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 . -# -############################################################################## +# © 2012 Agile Business Group +# © 2012 Domsense srl +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + from . import controllers diff --git a/web_export_view/__openerp__.py b/web_export_view/__openerp__.py index 0e3f5cad..a1f9efcc 100644 --- a/web_export_view/__openerp__.py +++ b/web_export_view/__openerp__.py @@ -1,27 +1,11 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2012 Agile Business Group sagl () -# Copyright (C) 2012 Domsense srl () -# -# 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 . -# -############################################################################## +# © 2012 Agile Business Group +# © 2012 Domsense srl +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'Export Current View', - 'version': '8.0.1.2.0', + 'version': '9.0.1.0.0', 'category': 'Web', 'author': "Agile Business Group,Odoo Community Association (OCA)", 'website': 'http://www.agilebg.com', @@ -32,9 +16,6 @@ 'data': [ 'view/web_export_view.xml', ], - 'qweb': [ - 'static/src/xml/web_export_view_template.xml', - ], - 'installable': False, + 'installable': True, 'auto_install': False, } diff --git a/web_export_view/controllers/__init__.py b/web_export_view/controllers/__init__.py index 9a651413..0e4e530c 100644 --- a/web_export_view/controllers/__init__.py +++ b/web_export_view/controllers/__init__.py @@ -1,21 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2012 Agile Business Group sagl () -# Copyright (C) 2012 Domsense srl () -# -# 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 . -# -############################################################################## +# © 2012 Agile Business Group +# © 2012 Domsense srl +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + from . import controllers diff --git a/web_export_view/controllers/controllers.py b/web_export_view/controllers/controllers.py index a38eec52..93acb968 100644 --- a/web_export_view/controllers/controllers.py +++ b/web_export_view/controllers/controllers.py @@ -1,24 +1,8 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2012 Domsense srl () -# Copyright (C) 2012-2013: -# Agile Business Group sagl () -# -# 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 . -# -############################################################################## +# © 2012 Agile Business Group +# © 2012 Domsense srl +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + try: import json except ImportError: diff --git a/web_export_view/static/src/js/web_export_view.js b/web_export_view/static/src/js/web_export_view.js index 00cb047e..ae8c800b 100644 --- a/web_export_view/static/src/js/web_export_view.js +++ b/web_export_view/static/src/js/web_export_view.js @@ -1,117 +1,119 @@ -// @@@ web_export_view custom JS @@@ -//############################################################################# -// -// Copyright (C) 2012 Agile Business Group sagl () -// Copyright (C) 2012 Therp BV () -// -// 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 . -// -//############################################################################# -openerp.web_export_view = function (instance) { +//# -*- coding: utf-8 -*- +//# © 2012 Agile Business Group +//# © 2012 Therp BV +//# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - var _t = instance.web._t, QWeb = instance.web.qweb; +odoo.define('web_export_view.Sidebar', function (require) { +"use strict"; - instance.web.Sidebar.include({ - redraw: function () { - var self = this; - 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); +var core = require('web.core'); +var Sidebar = require('web.Sidebar'); + +var _t = core._t; + +Sidebar.include({ + init: function () { + var self = this; + this._super.apply(this, arguments); + self.sections.push({ + name: 'export_current_view', + label: _t('Export Current View') + }); + self.items['export_current_view'] = []; + var view = self.getParent(); + if (view.fields_view && view.fields_view.type === "tree") { + self.web_export_add_items(); + } + }, + + web_export_add_items: function () { + var self = this; + self.add_items('export_current_view', [{ + label: 'Excel', + callback: self.on_sidebar_export_view_xls, + },]); + }, + + on_sidebar_export_view_xls: function () { + // Select the first list of the current (form) view + // or assume the main view is a list view and use that + var self = this, + view = this.getParent(), + children = view.getChildren(); + if (children) { + children.every(function (child) { + if (child.field && child.field.type == 'one2many') { + view = child.viewmanager.views.list.controller; + return false; // break out of the loop + } + if (child.field && child.field.type == 'many2many') { + view = child.list_view; + return false; // break out of the loop + } + return true; + }); + } + var export_columns_keys = []; + var export_columns_names = []; + $.each(view.visible_columns, function () { + if (this.tag == 'field') { + // non-fields like `_group` or buttons + export_columns_keys.push(this.id); + export_columns_names.push(this.string); } - }, + }); + var rows = view.$el.find('tbody tr[data-id]'); + var export_rows = []; + $.each(rows, function () { + var $row = $(this); + var export_row = []; + var row_selector = '.o_list_record_selector input[type=checkbox],\ + .oe_list_record_selector input[type=checkbox]'; + var checked = $row.find(row_selector).is(':checked'); + if (children && checked === true) { + $.each(export_columns_keys, function () { + var cell = $row.find('td[data-field="' + this + '"]').get(0); + var 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 = $('
' + cell.innerHTML + '
'); + if (data_id.find('input').get(0).checked) { + export_row.push(_t("True")); + } + else { + 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); - on_sidebar_export_view_xls: function () { - // Select the first list of the current (form) view - // or assume the main view is a list view and use that - var self = this, - view = this.getParent(), - children = view.getChildren(); - if (children) { - children.every(function (child) { - if (child.field && child.field.type == 'one2many') { - view = child.viewmanager.views.list.controller; - return false; // break out of the loop + export_row.push(parseInt(tmp2)); } - if (child.field && child.field.type == 'many2many') { - view = child.list_view; - return false; // break out of the loop + else { + export_row.push(text.trim()); } - return true; }); + export_rows.push(export_row); } - export_columns_keys = []; - export_columns_names = []; - $.each(view.visible_columns, function () { - if (this.tag == 'field') { - // non-fields like `_group` or buttons - export_columns_keys.push(this.id); - export_columns_names.push(this.string); - } - }); - rows = view.$el.find('.oe_list_content > tbody > tr'); - export_rows = []; - $.each(rows, function () { - $row = $(this); - // find only rows with data - if ($row.attr('data-id')) { - export_row = []; - checked = $row.find('th input[type=checkbox]').attr("checked"); - if (children && checked === "checked") { - $.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 = $('
' + cell.innerHTML + '
'); - if (data_id.find('input').get(0).checked) { - export_row.push(_t("True")); - } - else { - 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); + }); + $.blockUI(); + view.session.get_file({ + url: '/web/export/xls_view', + data: {data: JSON.stringify({ + model: view.model, + headers: export_columns_names, + rows: export_rows + })}, + complete: $.unblockUI + }); + }, - export_row.push(parseInt(tmp2)); - } - else { - export_row.push(text.trim()); - } - }); - export_rows.push(export_row); - } - } - }); - $.blockUI(); - view.session.get_file({ - url: '/web/export/xls_view', - data: {data: JSON.stringify({ - model: view.model, - headers: export_columns_names, - rows: export_rows - })}, - complete: $.unblockUI - }); - } - }); +}); +}); -}; 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 deleted file mode 100644 index fbd855d9..00000000 --- a/web_export_view/static/src/xml/web_export_view_template.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - -
- -
    -
  • Excel
  • -
-
-
-
\ No newline at end of file diff --git a/web_export_view/view/web_export_view.xml b/web_export_view/view/web_export_view.xml index 502070f1..fa6b2073 100644 --- a/web_export_view/view/web_export_view.xml +++ b/web_export_view/view/web_export_view.xml @@ -2,7 +2,7 @@ -