You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2012 Agile Business Group
  3. # © 2012 Domsense srl
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. try:
  6. import json
  7. except ImportError:
  8. import simplejson as json
  9. import openerp.http as http
  10. from openerp.http import request
  11. from openerp.addons.web.controllers.main import ExcelExport
  12. class ExcelExportView(ExcelExport):
  13. def __getattribute__(self, name):
  14. if name == 'fmt':
  15. raise AttributeError()
  16. return super(ExcelExportView, self).__getattribute__(name)
  17. @http.route('/web/export/xls_view', type='http', auth='user')
  18. def export_xls_view(self, data, token):
  19. data = json.loads(data)
  20. model = data.get('model', [])
  21. columns_headers = data.get('headers', [])
  22. rows = data.get('rows', [])
  23. return request.make_response(
  24. self.from_data(columns_headers, rows),
  25. headers=[
  26. ('Content-Disposition', 'attachment; filename="%s"'
  27. % self.filename(model)),
  28. ('Content-Type', self.content_type)
  29. ],
  30. cookies={'fileToken': token}
  31. )