mirror of
https://gitlab.com/flectra-community/l10n-switzerland-flectra.git
synced 2024-11-17 03:22:03 +00:00
14a109dc87
[ADD] l10n_ch_zip [ADD] l10n_ch_bank_statement_import_postfinance
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
# Copyright 2019-TODAY Flectra
|
|
# Copyright 2019-TODAY Camptocamp SA
|
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
|
|
|
from werkzeug import exceptions
|
|
|
|
from flectra.http import Controller, route, request
|
|
|
|
|
|
class ReportController(Controller):
|
|
|
|
# ------------------------------------------------------
|
|
# Misc. route utils
|
|
# ------------------------------------------------------
|
|
@route(
|
|
['/report/qrcode', '/report/qrcode/<path:value>'],
|
|
type='http',
|
|
auth="public",
|
|
)
|
|
def report_qrcode(self, value, width=600, height=100, bar_border=4):
|
|
"""Contoller able to render barcode images thanks to reportlab.
|
|
|
|
This adds `bar_border` capability.
|
|
|
|
Samples:
|
|
<img t-att-src="'/report/qrcode/%s' % o.name"/>
|
|
<img t-att-src="'/report/qrcode/?value=%s&width=%s&height=%s' %
|
|
(o.name, 200, 200)"/>
|
|
|
|
:param bar_border: Size of blank border, use 0 to remove border.
|
|
"""
|
|
try:
|
|
qrcode = request.env['l10n_ch_qr_bill.swiss_qr_bill'].qrcode(
|
|
value, width=width, height=height, bar_border=bar_border
|
|
)
|
|
except (ValueError, AttributeError):
|
|
raise exceptions.HTTPException(
|
|
description='Cannot convert into qrcode.'
|
|
)
|
|
|
|
return request.make_response(
|
|
qrcode, headers=[('Content-Type', 'image/png')]
|
|
)
|