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.

17 lines
493 B

5 years ago
  1. from odoo import api, models
  2. import qrcode
  3. import io
  4. class IrActionsReport(models.Model):
  5. _inherit = 'ir.actions.report'
  6. @api.model
  7. def qr_generate(self, value, box_size=3, border=5, **kwargs):
  8. try:
  9. qr = qrcode.make(value, box_size=box_size, border=border, **kwargs)
  10. arr = io.BytesIO()
  11. qr.save(arr, format='png')
  12. return arr.getvalue()
  13. except Exception:
  14. raise ValueError("Cannot convert into barcode.")