Browse Source

Migrate web_export_view to v 8.0

pull/27/head
Adil Houmadi 10 years ago
parent
commit
5ecec62023
  1. 4
      web_export_view/__init__.py
  2. 15
      web_export_view/__openerp__.py
  3. 21
      web_export_view/controllers/__init__.py
  4. 27
      web_export_view/controllers/controllers.py
  5. 8
      web_export_view/static/src/js/web_export_view.js
  6. 3
      web_export_view/static/src/xml/web_export_view_template.xml
  7. 11
      web_export_view/view/web_export_view.xml

4
web_export_view/__init__.py

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## ##############################################################################
#
#
# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>) # Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>) # Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
# #
@ -18,4 +18,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
import controllers
import controllers

15
web_export_view/__openerp__.py

@ -1,9 +1,8 @@
# -*- 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>)
# 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 # 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 # it under the terms of the GNU Affero General Public License as published
@ -22,7 +21,7 @@
{ {
'name': 'Export Current View', 'name': 'Export Current View',
'version': '1.1',
'version': '1.2',
'category': 'Web', 'category': 'Web',
'description': """ 'description': """
WEB EXPORT VIEW WEB EXPORT VIEW
@ -50,11 +49,11 @@ the same data of the tree view you are looking at, headers included.
'depends': [ 'depends': [
'web', 'web',
], ],
'js': [
'static/src/js/web_advanced_export.js',
'data': [
'view/web_export_view.xml',
], ],
'qweb': [ 'qweb': [
'static/src/xml/web_advanced_export.xml',
'static/src/xml/web_export_view_template.xml',
], ],
'installable': True, 'installable': True,
'auto_install': False, 'auto_install': False,

21
web_export_view/controllers/__init__.py

@ -0,0 +1,21 @@
# -*- 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/>.
#
##############################################################################
import controllers

27
web_export_view/controllers.py → web_export_view/controllers/controllers.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #############################################################################
##############################################################################
# #
# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>) # Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>) # Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
@ -23,33 +23,30 @@ try:
except ImportError: except ImportError:
import simplejson as json import simplejson as json
import openerp
import openerp.http as http import openerp.http as http
from openerp.http import request from openerp.http import request
from openerp.addons.web.controllers.main import ExcelExport from openerp.addons.web.controllers.main import ExcelExport
class ExcelExportView(ExcelExport): class ExcelExportView(ExcelExport):
_cp_path = '/web/export/xls_view'
def __getattribute__(self, name): def __getattribute__(self, name):
if name == 'fmt': if name == 'fmt':
raise AttributeError() raise AttributeError()
return super(ExcelExportView, self).__getattribute__(name) return super(ExcelExportView, self).__getattribute__(name)
@http.route('/web/export/xls_view', type='json', auth='user')
@http.route('/web/export/xls_view', type='http', auth='user')
def index(self, data, token): def index(self, data, token):
data = json.loads(data) data = json.loads(data)
model = data.get('model', []) model = data.get('model', [])
columns_headers = data.get('headers', []) columns_headers = data.get('headers', [])
rows = data.get('rows', []) 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 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}
)

8
web_export_view/static/src/js/web_advanced_export.js → web_export_view/static/src/js/web_export_view.js

@ -18,7 +18,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
//############################################################################# //#############################################################################
openerp.web_export_view = function (instance) { openerp.web_export_view = function (instance) {
debugger; debugger;
@ -94,21 +93,20 @@ openerp.web_export_view = function (instance) {
}); });
export_rows.push(export_row); export_rows.push(export_row);
} }
;
} }
}); });
$.blockUI(); $.blockUI();
debugger;
view.session.get_file({ view.session.get_file({
url: '/web/export/xls_view', url: '/web/export/xls_view',
data: {data: JSON.stringify({ data: {data: JSON.stringify({
model: view.model, model: view.model,
headers: export_columns_names, headers: export_columns_names,
rows: export_rows,
rows: export_rows
})}, })},
complete: $.unblockUI complete: $.unblockUI
}); });
},
}
}); });
}; };

3
web_export_view/static/src/xml/web_advanced_export.xml → web_export_view/static/src/xml/web_export_view_template.xml

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- vim:fdl=1:
-->
<templates id="template" xml:space="preserve"> <templates id="template" xml:space="preserve">
<t t-name="AddExportViewMain"> <t t-name="AddExportViewMain">
<div class="oe_form_dropdown_section"> <div class="oe_form_dropdown_section">

11
web_export_view/view/web_export_view.xml

@ -0,0 +1,11 @@
<?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>
Loading…
Cancel
Save