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.

24 lines
928 B

6 years ago
6 years ago
6 years ago
6 years ago
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2019 Creu Blanca
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. import werkzeug
  5. from odoo import http
  6. from odoo.http import request
  7. class Home(http.Controller):
  8. @http.route('/report/qr', type='http', auth="public")
  9. def report_qr(self, value, box_size=3, border=3, factory='png', **kwargs):
  10. try:
  11. barcode = request.env['report'].qr_generate(
  12. value, box_size=box_size, border=border,
  13. factory=factory, **kwargs)
  14. except (ValueError, AttributeError):
  15. raise werkzeug.exceptions.HTTPException(
  16. description='Cannot convert into barcode.')
  17. if factory != 'png':
  18. return request.make_response(
  19. barcode, headers=[('Content-Type', 'image/svg+xml')])
  20. return request.make_response(
  21. barcode, headers=[('Content-Type', 'image/png')])