OCA reporting engine fork for dev and update.
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.

40 lines
1.7 KiB

  1. # -*- encoding: utf-8 -*-
  2. # Odoo, Open Source Management Solution
  3. # Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU Affero General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU Affero General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. from openerp.http import route
  18. from openerp.addons.report.controllers import main as report
  19. class ReportController(report.ReportController):
  20. @route()
  21. def report_routes(self, reportname, docids=None, converter=None, **data):
  22. # Trick the main reporter to think we want an HTML report
  23. new_converter = converter if converter != "xml" else "html"
  24. response = super(ReportController, self).report_routes(
  25. reportname, docids, new_converter, **data)
  26. # If it was an XML report, just download the generated response
  27. if converter == "xml":
  28. # XML header must be before any spaces, and it is a common error,
  29. # so let's fix that here and make developers happier
  30. response.data = response.data.strip()
  31. # XML files should be downloaded
  32. response.headers.set("Content-Type", "text/xml")
  33. return response