From a0c192e8e0d49486de05010778a4a8c3ca4890f4 Mon Sep 17 00:00:00 2001 From: Adil Houmadi Date: Sat, 26 Jul 2014 13:57:10 +0200 Subject: [PATCH] Move plugin for __unported__ dir --- .../AUTHORS.txt | 0 .../__init__.py | 0 .../__openerp__.py | 24 ++++---- .../controllers.py | 33 ++++++----- .../i18n/de.po | 0 .../i18n/es.po | 0 .../i18n/fr.po | 0 .../i18n/is.po | 0 .../i18n/nl.po | 0 .../i18n/web_export_view.pot | 0 .../static/src}/js/web_advanced_export.js | 58 ++++++++++--------- .../static/src}/xml/web_advanced_export.xml | 2 +- 12 files changed, 61 insertions(+), 56 deletions(-) rename {__unported__/web_export_view => web_export_view}/AUTHORS.txt (100%) rename {__unported__/web_export_view => web_export_view}/__init__.py (100%) rename {__unported__/web_export_view => web_export_view}/__openerp__.py (81%) rename {__unported__/web_export_view => web_export_view}/controllers.py (67%) rename {__unported__/web_export_view => web_export_view}/i18n/de.po (100%) rename {__unported__/web_export_view => web_export_view}/i18n/es.po (100%) rename {__unported__/web_export_view => web_export_view}/i18n/fr.po (100%) rename {__unported__/web_export_view => web_export_view}/i18n/is.po (100%) rename {__unported__/web_export_view => web_export_view}/i18n/nl.po (100%) rename {__unported__/web_export_view => web_export_view}/i18n/web_export_view.pot (100%) rename {__unported__/web_export_view/static => web_export_view/static/src}/js/web_advanced_export.js (72%) rename {__unported__/web_export_view/static => web_export_view/static/src}/xml/web_advanced_export.xml (96%) diff --git a/__unported__/web_export_view/AUTHORS.txt b/web_export_view/AUTHORS.txt similarity index 100% rename from __unported__/web_export_view/AUTHORS.txt rename to web_export_view/AUTHORS.txt diff --git a/__unported__/web_export_view/__init__.py b/web_export_view/__init__.py similarity index 100% rename from __unported__/web_export_view/__init__.py rename to web_export_view/__init__.py diff --git a/__unported__/web_export_view/__openerp__.py b/web_export_view/__openerp__.py similarity index 81% rename from __unported__/web_export_view/__openerp__.py rename to web_export_view/__openerp__.py index 632c7ee4..37ab5ede 100644 --- a/__unported__/web_export_view/__openerp__.py +++ b/web_export_view/__openerp__.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -############################################################################## +# ############################################################################# # -# Copyright (C) 2012 Domsense srl () -# Copyright (C) 2012-2013 Agile Business Group sagl +# 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 @@ -47,13 +47,15 @@ the same data of the tree view you are looking at, headers included. 'author': 'Agile Business Group', 'website': 'http://www.agilebg.com', 'license': 'AGPL-3', - 'depends': ['web'], - # 'external_dependencies': { - # 'python': ['xlwt'], - # }, - 'js': ['static/*/*.js', 'static/*/js/*.js'], - 'qweb': ['static/xml/web_advanced_export.xml'], - 'installable': False, + 'depends': [ + 'web', + ], + 'js': [ + 'static/src/js/web_advanced_export.js', + ], + 'qweb': [ + 'static/src/xml/web_advanced_export.xml', + ], + 'installable': True, 'auto_install': False, - 'web_preload': False, } diff --git a/__unported__/web_export_view/controllers.py b/web_export_view/controllers.py similarity index 67% rename from __unported__/web_export_view/controllers.py rename to web_export_view/controllers.py index 01e3e1f9..82968ffe 100644 --- a/__unported__/web_export_view/controllers.py +++ b/web_export_view/controllers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# ############################################################################# # # Copyright (C) 2012 Agile Business Group sagl () # Copyright (C) 2012 Domsense srl () @@ -23,9 +23,10 @@ try: except ImportError: import simplejson as json -import web.http as openerpweb - -from web.controllers.main import ExcelExport +import openerp +import openerp.http as http +from openerp.http import request +from openerp.addons.web.controllers.main import ExcelExport class ExcelExportView(ExcelExport): @@ -36,19 +37,19 @@ class ExcelExportView(ExcelExport): raise AttributeError() return super(ExcelExportView, self).__getattribute__(name) - @openerpweb.httprequest - def index(self, req, data, token): + @http.route('/web/export/xls_view', type='json', auth='user') + def index(self, data, token): data = json.loads(data) model = data.get('model', []) columns_headers = data.get('headers', []) rows = data.get('rows', []) - - return req.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} - ) + # + # return req.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/__unported__/web_export_view/i18n/de.po b/web_export_view/i18n/de.po similarity index 100% rename from __unported__/web_export_view/i18n/de.po rename to web_export_view/i18n/de.po diff --git a/__unported__/web_export_view/i18n/es.po b/web_export_view/i18n/es.po similarity index 100% rename from __unported__/web_export_view/i18n/es.po rename to web_export_view/i18n/es.po diff --git a/__unported__/web_export_view/i18n/fr.po b/web_export_view/i18n/fr.po similarity index 100% rename from __unported__/web_export_view/i18n/fr.po rename to web_export_view/i18n/fr.po diff --git a/__unported__/web_export_view/i18n/is.po b/web_export_view/i18n/is.po similarity index 100% rename from __unported__/web_export_view/i18n/is.po rename to web_export_view/i18n/is.po diff --git a/__unported__/web_export_view/i18n/nl.po b/web_export_view/i18n/nl.po similarity index 100% rename from __unported__/web_export_view/i18n/nl.po rename to web_export_view/i18n/nl.po diff --git a/__unported__/web_export_view/i18n/web_export_view.pot b/web_export_view/i18n/web_export_view.pot similarity index 100% rename from __unported__/web_export_view/i18n/web_export_view.pot rename to web_export_view/i18n/web_export_view.pot diff --git a/__unported__/web_export_view/static/js/web_advanced_export.js b/web_export_view/static/src/js/web_advanced_export.js similarity index 72% rename from __unported__/web_export_view/static/js/web_advanced_export.js rename to web_export_view/static/src/js/web_advanced_export.js index 36ba128a..4b096b53 100644 --- a/__unported__/web_export_view/static/js/web_advanced_export.js +++ b/web_export_view/static/src/js/web_advanced_export.js @@ -19,27 +19,28 @@ // //############################################################################# -openerp.web_export_view = function(instance, m) { +openerp.web_export_view = function (instance) { + debugger; var _t = instance.web._t, - QWeb = instance.web.qweb; + QWeb = instance.web.qweb; instance.web.Sidebar.include({ - redraw: function() { + redraw: function () { var self = this; this._super.apply(this, arguments); 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); }, - on_sidebar_export_view_xls: function() { + 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(); + view = this.getParent(), + children = view.getChildren(); if (children) { - children.every(function(child) { + children.every(function (child) { if (child.field && child.field.type == 'one2many') { view = child.viewmanager.views.list.controller; return false; // break out of the loop @@ -53,8 +54,8 @@ openerp.web_export_view = function(instance, m) { } export_columns_keys = []; export_columns_names = []; - $.each(view.visible_columns, function(){ - if(this.tag=='field'){ + $.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); @@ -62,46 +63,47 @@ openerp.web_export_view = function(instance, m) { }); rows = view.$el.find('.oe_list_content > tbody > tr'); export_rows = []; - $.each(rows,function(){ + $.each(rows, function () { $row = $(this); // 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"){ - $.each(export_columns_keys,function(){ - cell = $row.find('td[data-field="'+this+'"]').get(0); + 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")){ + 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 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")); + export_row.push(_t("False")); } } - else if (cell.classList.contains("oe_list_field_integer")){ - export_row.push(parseInt(text)); + else if (cell.classList.contains("oe_list_field_integer")) { + export_row.push(parseInt(text)); } - else{ - export_row.push(text.trim()); + 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, + model: view.model, + headers: export_columns_names, + rows: export_rows, })}, complete: $.unblockUI }); diff --git a/__unported__/web_export_view/static/xml/web_advanced_export.xml b/web_export_view/static/src/xml/web_advanced_export.xml similarity index 96% rename from __unported__/web_export_view/static/xml/web_advanced_export.xml rename to web_export_view/static/src/xml/web_advanced_export.xml index cb4b5004..e5c48f5f 100644 --- a/__unported__/web_export_view/static/xml/web_advanced_export.xml +++ b/web_export_view/static/src/xml/web_advanced_export.xml @@ -10,4 +10,4 @@ - + \ No newline at end of file