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.

21 lines
817 B

5 years ago
5 years ago
5 years ago
5 years ago
  1. import werkzeug
  2. from odoo import http
  3. from odoo.http import request
  4. class Home(http.Controller):
  5. @http.route('/report/qr', type='http', auth="public")
  6. def report_qr(self, value, box_size=3, border=3, factory='png', **kwargs):
  7. try:
  8. barcode = request.env['ir.actions.report'].qr_generate(
  9. value, box_size=box_size, border=border,
  10. factory=factory, **kwargs)
  11. except (ValueError, AttributeError):
  12. raise werkzeug.exceptions.HTTPException(
  13. description='Cannot convert into barcode.')
  14. if factory != 'png':
  15. return request.make_response(
  16. barcode, headers=[('Content-Type', 'image/svg+xml')])
  17. return request.make_response(
  18. barcode, headers=[('Content-Type', 'image/png')])