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.

34 lines
1.1 KiB

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