From 0d327e2d81b0c7104ddf380719af2c8d4186f01b Mon Sep 17 00:00:00 2001 From: fw-bot Date: Thu, 18 Jun 2020 14:18:12 +0000 Subject: [PATCH] [FIX] l10n_ch: don't add an empty page on QR-bill pdf report when a header is displayed Before that, just one pixel from the bottom of the QR-bill frame passed got out of the page, and end out creating a second, empty page. Since this error was probably due to some rounding issue in the way A4 dimensions were compared to the layout specified by the scss file, we solve it by rounding the height of this section a little more, removing 0.25mm from it. [FIX] l10n_ch: qr bill report: display the payment ref under "reference" and the invoice's name as additional information closes odoo/odoo#53453 X-original-commit: 8a6cc1a572cd04f540e4a5e83362319c13274aea Signed-off-by: Laurent Smet Signed-off-by: oco-odoo --- addons/l10n_ch/models/account_invoice.py | 13 +++++++++++ addons/l10n_ch/report/swissqr_report.py | 2 +- addons/l10n_ch/report/swissqr_report.xml | 22 ++++++++----------- .../static/src/scss/report_swissqr.scss | 6 ++--- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/addons/l10n_ch/models/account_invoice.py b/addons/l10n_ch/models/account_invoice.py index c19afba614a..b0ff383c01a 100644 --- a/addons/l10n_ch/models/account_invoice.py +++ b/addons/l10n_ch/models/account_invoice.py @@ -219,3 +219,16 @@ class AccountMove(models.Model): """ self.ensure_one() return self.l10n_ch_isr_number + + @api.model + def space_qrr_reference(self, qrr_ref): + """ Makes the provided QRR reference human-friendly, spacing its elements + by blocks of 5 from right to left. + """ + spaced_qrr_ref = '' + i = len(qrr_ref) # i is the index after the last index to consider in substrings + while i > 0: + spaced_qrr_ref = qrr_ref[max(i-5, 0) : i] + ' ' + spaced_qrr_ref + i -= 5 + + return spaced_qrr_ref diff --git a/addons/l10n_ch/report/swissqr_report.py b/addons/l10n_ch/report/swissqr_report.py index 3e7ff833c40..9c3efd91f1a 100644 --- a/addons/l10n_ch/report/swissqr_report.py +++ b/addons/l10n_ch/report/swissqr_report.py @@ -12,7 +12,7 @@ class ReportSwissQR(models.AbstractModel): qr_code_urls = {} for invoice in docs: - qr_code_urls[invoice.id] = invoice.invoice_partner_bank_id.build_qr_code_url(invoice.amount_residual, invoice.ref or invoice.name, invoice.payment_reference, invoice.currency_id, invoice.partner_id, qr_method='ch_qr', silent_errors=False) + qr_code_urls[invoice.id] = invoice.partner_bank_id.build_qr_code_url(invoice.amount_residual, invoice.ref or invoice.name, invoice.payment_reference, invoice.currency_id, invoice.partner_id, qr_method='ch_qr', silent_errors=False) return { 'doc_ids': docids, diff --git a/addons/l10n_ch/report/swissqr_report.xml b/addons/l10n_ch/report/swissqr_report.xml index 6e892d80b01..8df6286e2a3 100644 --- a/addons/l10n_ch/report/swissqr_report.xml +++ b/addons/l10n_ch/report/swissqr_report.xml @@ -43,12 +43,9 @@
- Reference
- -
-
- -
+ + Reference
+
Payable by
@@ -88,16 +85,15 @@
- Reference
- -
-
- -
+ + Reference
+
Additional information
-
+ + +
Payable by

diff --git a/addons/l10n_ch/static/src/scss/report_swissqr.scss b/addons/l10n_ch/static/src/scss/report_swissqr.scss index 09070311c33..379ac0690a4 100644 --- a/addons/l10n_ch/static/src/scss/report_swissqr.scss +++ b/addons/l10n_ch/static/src/scss/report_swissqr.scss @@ -14,7 +14,7 @@ body.l10n_ch_qr { } .swissqr_content { - position: relative; + position: static; } .swissqr_receipt { @@ -23,7 +23,7 @@ body.l10n_ch_qr { border-color:black; border-width: 1pt 1pt 1pt 1pt; border-style: solid; - height: 131.25mm; /* 105 * 1.25 */ + height: 131mm; /* 105 * 1.25 - 0.25 mm to cope for rendering issues due to header (probably a rounding issue) */ width: 77.5mm; /* 62 * 1.25 */ top: 240mm; /* 192 * 1.25 */ left: 0mm; @@ -36,7 +36,7 @@ body.l10n_ch_qr { border-color:black; border-width: 1pt 1pt 1pt 1pt; border-style: solid; - height: 131.25mm; /* 105 * 1.25 */ + height: 131mm; /* 105 * 1.25 - 0.25mm to cope for rendering issues due to header (probably a rounding issue)*/ width: 185mm; /* 148 * 1.25 */ top: 240mm; /* 192 * 1.25 */ left: 77.5mm; /* 62 * 1.25 */