summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorfw-bot <otis@odoo.com>2020-06-18 14:18:12 +0000
committeroco-odoo <oco@odoo.com>2020-06-22 16:03:59 +0000
commit0d327e2d81b0c7104ddf380719af2c8d4186f01b (patch)
tree70a81695ace555be4878bc14f555c3620e6639e7 /addons
parenta220f05f4d63ffd4f29d28a2ec146e1c28b8a242 (diff)
[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 <smetl@users.noreply.github.com> Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/l10n_ch/models/account_invoice.py13
-rw-r--r--addons/l10n_ch/report/swissqr_report.py2
-rw-r--r--addons/l10n_ch/report/swissqr_report.xml22
-rw-r--r--addons/l10n_ch/static/src/scss/report_swissqr.scss6
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 @@
<span class="swissqr_text content" t-field="o.company_id.zip"/>
<span class="swissqr_text content" t-field="o.company_id.city"/><br/>
- <span class="swissqr_text title">Reference</span><br/>
- <t t-if="o.partner_bank_id.currency_id.name == 'EUR'">
- <span class="swissqr_text content" t-field="o.partner_bank_id.bank_id.l10n_ch_postal_eur"/><br/>
- </t>
- <t t-if="o.partner_bank_id.currency_id.name == 'CHF'">
- <span class="swissqr_text content" t-field="o.partner_bank_id.bank_id.l10n_ch_postal_chf"/><br/>
+ <t t-if="o.partner_bank_id._is_qr_iban()">
+ <span class="swissqr_text title">Reference</span><br/>
+ <span class="swissqr_text content" t-esc="o.space_qrr_reference(o.payment_reference)"/><br/>
</t>
<span class="swissqr_text title">Payable by</span><br/>
@@ -88,16 +85,15 @@
<span class="swissqr_text content" t-field="o.company_id.zip"/>
<span class="swissqr_text content" t-field="o.company_id.city"/><br/>
- <span class="swissqr_text title">Reference</span><br/>
- <t t-if="o.partner_bank_id.currency_id.name == 'EUR'">
- <span class="swissqr_text content" t-field="o.partner_bank_id.l10n_ch_isr_subscription_eur"/><br/>
- </t>
- <t t-if="o.partner_bank_id.currency_id.name == 'CHF'">
- <span class="swissqr_text content" t-field="o.partner_bank_id.l10n_ch_isr_subscription_chf"/><br/>
+ <t t-if="o.partner_bank_id._is_qr_iban()">
+ <span class="swissqr_text title">Reference</span><br/>
+ <span class="swissqr_text content" t-esc="o.space_qrr_reference(o.payment_reference)"/><br/>
</t>
<span class="swissqr_text title">Additional information</span><br/>
- <span class="swissqr_text content" t-field="o.ref"/><br/>
+ <span class="swissqr_text content" t-esc="o.payment_reference or o.ref or o.name" t-if="not o.partner_bank_id._is_qr_iban()"/>
+ <span class="swissqr_text content" t-esc="o.ref or o.name" t-if="o.partner_bank_id._is_qr_iban()"/>
+ <br/>
<span class="swissqr_text title">Payable by</span><br/>
<span class="swissqr_text content" t-field="o.partner_id.name"/><br/>
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 */