mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[ADD] report_qr
This commit is contained in:
committed by
Kiplangat Dan
parent
a30062fae2
commit
ccdc3d7b6c
17
report_qr/models/ir_actions_report.py
Normal file
17
report_qr/models/ir_actions_report.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from odoo import api, models
|
||||
import qrcode
|
||||
import io
|
||||
|
||||
|
||||
class IrActionsReport(models.Model):
|
||||
_inherit = 'ir.actions.report'
|
||||
|
||||
@api.model
|
||||
def qr_generate(self, value, box_size=3, border=5, **kwargs):
|
||||
try:
|
||||
qr = qrcode.make(value, box_size=box_size, border=border, **kwargs)
|
||||
arr = io.BytesIO()
|
||||
qr.save(arr, format='png')
|
||||
return arr.getvalue()
|
||||
except Exception:
|
||||
raise ValueError("Cannot convert into barcode.")
|
||||
Reference in New Issue
Block a user