summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorChristophe Monniez <moc@odoo.com>2020-10-30 11:23:49 +0000
committerChristophe Monniez <moc@odoo.com>2020-10-30 11:23:49 +0000
commitd33785032b1ca2c6e1d4ade7e174d024fae9a151 (patch)
tree0ea5cfa9729995f8498d178789e6f7ffefeffc81 /addons
parent3ab451f3c4ce8dd42337f43628c1335d2caee011 (diff)
[FIX] l10n_ch: use an absolute path for ch flag
When printing an invoice with an iban qrcode using l10n_ch module, a little ch flag appears in the center of the qr code. When odoo is started from elsewhere than the root of the odoo code, the flag does not appear. The cause is that a relative path is used to find the flag image. With this commit, an absolute path is computed to find the flag. closes odoo/odoo#61043 Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/l10n_ch/models/ir_actions_report.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/addons/l10n_ch/models/ir_actions_report.py b/addons/l10n_ch/models/ir_actions_report.py
index c77137c8ea6..7b09f53cd83 100644
--- a/addons/l10n_ch/models/ir_actions_report.py
+++ b/addons/l10n_ch/models/ir_actions_report.py
@@ -3,11 +3,12 @@
from odoo import api, models
+from pathlib import Path
from reportlab.graphics.shapes import Image as ReportLabImage
from reportlab.lib.units import mm
CH_QR_CROSS_SIZE_RATIO = 0.1214 # Ratio between the side length of the Swiss QR-code cross image and the QR-code's
-CH_QR_CROSS_FILE = 'addons/l10n_ch/static/src/img/CH-Cross_7mm.png' # Image file containing the Swiss QR-code cross to add on top of the QR-code
+CH_QR_CROSS_FILE = Path('../static/src/img/CH-Cross_7mm.png') # Image file containing the Swiss QR-code cross to add on top of the QR-code
class IrActionsReport(models.Model):
_inherit = 'ir.actions.report'
@@ -22,5 +23,6 @@ class IrActionsReport(models.Model):
def apply_qr_code_ch_cross_mask(self, width, height, barcode_drawing):
cross_width = CH_QR_CROSS_SIZE_RATIO * width
cross_height = CH_QR_CROSS_SIZE_RATIO * height
- qr_cross = ReportLabImage((width/2 - cross_width/2) / mm, (height/2 - cross_height/2) / mm, cross_width / mm, cross_height / mm, CH_QR_CROSS_FILE)
- barcode_drawing.add(qr_cross) \ No newline at end of file
+ cross_path = Path(__file__).absolute().parent / CH_QR_CROSS_FILE
+ qr_cross = ReportLabImage((width/2 - cross_width/2) / mm, (height/2 - cross_height/2) / mm, cross_width / mm, cross_height / mm, cross_path.as_posix())
+ barcode_drawing.add(qr_cross)