mirror of
https://gitlab.com/flectra-community/l10n-switzerland-flectra.git
synced 2024-12-24 13:21:46 +00:00
14a109dc87
[ADD] l10n_ch_zip [ADD] l10n_ch_bank_statement_import_postfinance
29 lines
878 B
Python
29 lines
878 B
Python
# Part of Flectra. See LICENSE file for full copyright and licensing details.
|
|
from flectra import api, models
|
|
|
|
from reportlab.graphics.barcode import createBarcodeDrawing
|
|
|
|
|
|
class SwissQrBill(models.Model):
|
|
_name = 'l10n_ch_qr_bill.swiss_qr_bill'
|
|
|
|
@api.model
|
|
def qrcode(self, value, width=600, height=100, bar_border=4):
|
|
try:
|
|
width, height, bar_border = (
|
|
int(width),
|
|
int(height),
|
|
int(bar_border),
|
|
)
|
|
|
|
qrcode = createBarcodeDrawing(
|
|
"QR",
|
|
value=value,
|
|
format='png',
|
|
width=width,
|
|
height=height,
|
|
barBorder=bar_border,
|
|
)
|
|
return qrcode.asString('png')
|
|
except (ValueError, AttributeError):
|
|
raise ValueError("Cannot convert into QR code.") |