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.

35 lines
1.2 KiB

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