[FIX] l10n_ch: Fix QR bill according to specs

Reworked the structure of the HTML and the SCSS
to adhere to the official specs:

- 5mm padding inside the two main sections
- Correct font sizes
- Bold headers
- Increased the Swiss Cross inside the logo (7mm x 7mm)
- Scissors pictogram on the outline
- Dashed borders

Sizes now take the wkhtmltopdf (1/1.25 factor) shrinking
into consideration.

closes odoo/odoo#80544

X-original-commit: f02622684c6a220a425044d8d4a5fd474efdb519
Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
Paolo (pgi)
2021-12-02 10:18:56 +00:00
parent 8891f25872
commit f3e9e6f4b6
8 changed files with 368 additions and 180 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ 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_SIZE_RATIO = 0.1522 # Ratio between the side length of the Swiss QR-code cross image and the QR-code's
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):
+121 -70
View File
@@ -16,62 +16,84 @@
<template id="l10n_ch_swissqr_template">
<t t-set="o" t-value="o.with_context(lang=lang)"/>
<t t-call="web.external_layout">
<!-- add default margin for header (matching A4 European margin) -->
<t t-set="report_header_style">padding-top:6.2mm; padding-left:8.2mm; padding-right:8.2mm;</t>
<t t-set="formated_amount" t-value="'{:,.2f}'.format(o.amount_residual).replace(',','\xa0')"/>
<div class="swissqr_title">
<div class="swissqr_page_title">
<h1>QR-bill for invoice <t t-esc="o.name"/></h1>
</div>
<div class="swissqr_content">
<div class="swissqr_content_v2">
<div class="swissqr_receipt">
<div id="receipt_title_zone" class="main_title swissqr_column_left">
<img src="/l10n_ch/static/src/img/scissors_h.png" class="scissors horizontal_scissors"/>
<div id="receipt_title_zone" class="swissqr_section_title">
<span>Receipt</span>
</div>
<div id="receipt_indication_zone" class="swissqr_column_left receipt_indication_zone">
<div class="swissqr_text">
<span class="title">Account / Payable to</span><br/>
<span class="content" t-field="o.partner_bank_id.acc_number" t-if="not o.partner_bank_id.l10n_ch_qr_iban"/>
<span class="content" t-field="o.partner_bank_id.l10n_ch_qr_iban" t-if="o.partner_bank_id.l10n_ch_qr_iban"/>
<br/>
<span class="content" t-field="o.company_id.name"/><br/>
<span class="content" t-field="o.company_id.street"/><br/>
<span class="content" t-field="o.company_id.country_id.code"/>
<span class="content" t-field="o.company_id.zip"/>
<span class="content" t-field="o.company_id.city"/><br/>
<div id="receipt_indication_zone" class="receipt_indication_zone">
<div class="swissqr_text title">
<span>Account / Payable to</span>
</div>
<div class="swissqr_text content">
<span t-field="o.partner_bank_id.acc_number" t-if="not o.partner_bank_id.l10n_ch_qr_iban"/>
<span t-field="o.partner_bank_id.l10n_ch_qr_iban" t-if="o.partner_bank_id.l10n_ch_qr_iban"/>
<br/>
<span t-field="o.company_id.name"/><br/>
<span t-field="o.company_id.street"/><br/>
<span t-field="o.company_id.country_id.code"/>
<span t-field="o.company_id.zip"/>
<span t-field="o.company_id.city"/><br/>
<br/>
</div>
<t t-if="o.partner_bank_id.l10n_ch_qr_iban">
<div class="swissqr_text">
<span class="title">Reference</span><br/>
<span class="content" t-esc="o.space_qrr_reference(o.payment_reference)"/><br/>
<div class="swissqr_text title">
<span>Reference</span>
</div>
<div class="swissqr_text content">
<span t-esc="o.space_qrr_reference(o.payment_reference)"/><br/>
<br/>
</div>
</t>
<div class="swissqr_text">
<span class="title">Payable by</span><br/>
<span class="content" t-field="o.partner_id.commercial_partner_id.name"/><br/>
<span class="content" t-field="o.partner_id.street"> </span>
<span class="content" t-field="o.partner_id.street2"/><br/>
<span class="content" t-field="o.partner_id.country_id.code"/>
<span class="content" t-field="o.partner_id.zip"/>
<span class="content" t-field="o.partner_id.city"/><br/>
<div class="swissqr_text title">
<span>Payable by</span>
</div>
<div class="swissqr_text content">
<span t-field="o.partner_id.commercial_partner_id.name"/><br/>
<span t-field="o.partner_id.street"/>
<span t-field="o.partner_id.street2"/><br/>
<span t-field="o.partner_id.country_id.code"/>
<span t-field="o.partner_id.zip"/>
<span t-field="o.partner_id.city"/>
</div>
</div>
<div id="receipt_amount_zone" class="swissqr_column_left receipt_amount_zone">
<div class="swissqr_text">
<div class="column">
<span class="title">Currency</span><br/>
<span class="content" t-field="o.currency_id.name"/>
<div class="title">
<span>Currency</span>
</div>
<div class="content">
<span t-field="o.currency_id.name"/>
</div>
</div>
<div class="column">
<span class="title">Amount</span><br/>
<span class="content" t-esc="formated_amount"/>
<div class="title">
<span>Amount</span>
</div>
<div class="content">
<span t-esc="formated_amount"/>
</div>
</div>
</div>
</div>
@@ -81,68 +103,97 @@
<span class="title">Acceptance point</span>
</div>
</div>
</div>
<div class="swissqr_body">
<div class="main_title swissqr_column_left">
<span>Payment Part</span>
<img src="/l10n_ch/static/src/img/scissors_v.png" class="scissors vertical_scissors"/>
<div class="swissqr_column_left">
<div class="swissqr_section_title">
<span>Payment part</span>
</div>
<img class="swissqr" t-att-src="qr_code_urls[o.id]"/>
<div id="amount_zone" class="amount_zone">
<div class="swissqr_text">
<div class="column">
<div class="title">
<span>Currency</span>
</div>
<div class="content">
<span t-field="o.currency_id.name"/>
</div>
</div>
<div class="column">
<div class="title">
<span>Amount</span><br/>
</div>
<div class="content">
<span t-esc="formated_amount"/>
</div>
</div>
</div>
</div>
</div>
<img class="swissqr" t-att-src="qr_code_urls[o.id]"/>
<div id="indications_zone" class="swissqr_column_right indication_zone">
<div class="swissqr_text">
<span class="title">Account / Payable to</span><br/>
<span class="content" t-field="o.partner_bank_id.acc_number" t-if="not o.partner_bank_id.l10n_ch_qr_iban"/>
<span class="content" t-field="o.partner_bank_id.l10n_ch_qr_iban" t-if="o.partner_bank_id.l10n_ch_qr_iban"/>
<div id="indications_zone" class="swissqr_column_right">
<div class="swissqr_text title">
<span>Account / Payable to</span><br/>
</div>
<div class="swissqr_text content">
<span t-field="o.partner_bank_id.acc_number" t-if="not o.partner_bank_id.l10n_ch_qr_iban"/>
<span t-field="o.partner_bank_id.l10n_ch_qr_iban" t-if="o.partner_bank_id.l10n_ch_qr_iban"/>
<br/>
<span t-field="o.company_id.name"/><br/>
<span t-field="o.company_id.street"/><br/>
<span t-field="o.company_id.country_id.code"/>
<span t-field="o.company_id.zip"/>
<span t-field="o.company_id.city"/><br/>
<br/>
<span class="content" t-field="o.company_id.name"/><br/>
<span class="content" t-field="o.company_id.street"/><br/>
<span class="content" t-field="o.company_id.country_id.code"/>
<span class="content" t-field="o.company_id.zip"/>
<span class="content" t-field="o.company_id.city"/><br/>
</div>
<t t-if="o.partner_bank_id.l10n_ch_qr_iban">
<div class="swissqr_text">
<span class="title">Reference</span><br/>
<span class="content" t-esc="o.space_qrr_reference(o.payment_reference)"/><br/>
<div class="swissqr_text title">
<span class="title">Reference</span>
</div>
<div class="swissqr_text content">
<span t-esc="o.space_qrr_reference(o.payment_reference)"/><br/>
<br/>
</div>
</t>
<t t-set="additional_info" t-value="(o.ref or o.name if o.partner_bank_id.l10n_ch_qr_iban else o.payment_reference or o.ref or o.name)"/>
<t t-if="additional_info">
<div class="swissqr_text">
<span class="title">Additional information</span><br/>
<span class="content" t-esc="additional_info"/>
<div class="swissqr_text title">
<span>Additional information</span>
</div>
<div class="swissqr_text content">
<span t-esc="additional_info"/><br/>
<br/>
</div>
</t>
<div class="swissqr_text">
<span class="title">Payable by</span><br/>
<span class="content" t-field="o.partner_id.commercial_partner_id.name"/><br/>
<span class="content" t-field="o.partner_id.street"> </span>
<span class="content" t-field="o.partner_id.street2"/><br/>
<span class="content" t-field="o.partner_id.country_id.code"/>
<span class="content" t-field="o.partner_id.zip"/>
<span class="content" t-field="o.partner_id.city"/><br/>
<div class="swissqr_text title">
<span>Payable by</span>
</div>
<div class="swissqr_text content">
<span t-field="o.partner_id.commercial_partner_id.name"/><br/>
<span t-field="o.partner_id.street"> </span>
<span t-field="o.partner_id.street2"/><br/>
<span t-field="o.partner_id.country_id.code"/>
<span t-field="o.partner_id.zip"/>
<span t-field="o.partner_id.city"/><br/>
<br/>
</div>
</div>
<div id="amount_zone" class="swissqr_column_left amount_zone">
<div class="swissqr_text">
<div class="column">
<span class="title">Currency</span><br/>
<span class="content" t-field="o.currency_id.name"/>
</div>
<div class="column">
<span class="title">Amount</span><br/>
<span class="content" t-esc="formated_amount"/>
</div>
</div>
</div>
</div>
</div>
</t>
</template>
@@ -0,0 +1,102 @@
Digitized data copyright (c) 2010 Google Corporation
with Reserved Font Arimo, Tinos and Cousine.
Copyright (c) 2012 Red Hat, Inc.
with Reserved Font Name Liberation.
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
PREAMBLE The goals of the Open Font License (OFL) are to stimulate
worldwide development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to provide
a free and open framework in which fonts may be shared and improved in
partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves.
The fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such.
This may include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components
as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting ? in part or in whole ?
any of the components of the Original Version, by changing formats or
by porting the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical writer
or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining a
copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,in
Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole, must
be distributed entirely under this license, and must not be distributed
under any other license. The requirement for fonts to remain under
this license does not apply to any document created using the Font
Software.
TERMINATION
This license becomes null and void if any of the above conditions are not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER
DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

+144 -109
View File
@@ -1,3 +1,14 @@
@font-face {
font-family: LiberationSans;
src: url('../font/LiberationSans-Bold.woff') format('woff');
font-weight: bold;
}
@font-face {
font-family: LiberationSans;
src: url('../font/LiberationSans-Regular.woff') format('woff');
}
body {
padding: 0!important;
@@ -6,140 +17,164 @@ body {
background: none;
min-height: 0;
}
}
.swissqr_title {
position: absolute;
.swissqr_content_v2 {
/* New QR Bill code */
background-color: white;
/* Disable custom font-family */
.o_company_2_layout {
font-family: revert;
}
$ratio: 1.25;
$receipt_width: 52mm * $ratio;
$left_col_width: 46mm * $ratio;
$right_col_width: 87mm * $ratio;
$rounding_offset: 0.25mm;
@mixin font {
font-family: LiberationSans;
color: black;
}
@mixin title {
@include font;
font-weight: bold;
}
.title {
@include title;
}
.swissqr_text {
@include font;
}
.swissqr_page_title {
@include title;
height: 7mm * $ratio;
padding: 15px;
padding-top: 200px;
}
.swissqr_content {
position: static;
.swissqr_section_title {
@include title;
width: $receipt_width;
height: 7mm * $ratio;
font-size: 11pt * $ratio;
line-height: 9pt * $ratio;
}
.swissqr_receipt {
position: absolute;
background-color: white;
border-color:black;
border-width: 1pt 1pt 1pt 1pt;
border-style: solid;
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;
/*These measures are multiplied by 1.25 here to fit the canvas size used by our reporting engine (1.25 times bigger than A4)*/
top: 192mm * $ratio;
width: 62mm * $ratio;
height: 105mm * $ratio - $rounding_offset;
border: 0.75pt * $ratio dashed black;
border-right: 0pt;
padding: 5mm * $ratio;
.title {
font-size: 6pt * $ratio;
line-height: 9pt * $ratio;
}
.content {
font-size: 8pt * $ratio;
line-height: 9pt * $ratio;
}
.receipt_indication_zone {
width: $receipt_width;
height: 56mm * $ratio;
}
.receipt_amount_zone {
width: $receipt_width;
height: 14mm * $ratio;
.column {
float: left;
margin-right: 5mm;
}
.content {
font-size: 8pt * $ratio;
line-height: 11pt * $ratio;
}
}
.receipt_acceptance_point_zone {
width: $receipt_width;
height: 18mm * $ratio;
.content {
float: right;
padding-right: 2mm * $ratio;
font-size: 6pt * $ratio;
line-height: 8pt * $ratio;
}
}
}
.swissqr_body {
position: absolute;
background-color: white;
border-color:black;
border-width: 1pt 1pt 1pt 1pt;
border-style: solid;
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 */
/*These measures are multiplied by 1.25 here to fit the canvas size used by our reporting engine (1.25 times bigger than A4)*/
}
.swissqr {
position: absolute;
height: 57.5mm; /* 46 * 1.25 */
width: 57.5mm; /* 46 * 1.25 */
top: 20mm; /* 16 * 1.25 */
left: 6.25mm; /* 5 * 1.25 min readability margin for QR */
/*These measures are multiplied by 1.25 here to fit the canvas size used by our reporting engine (1.25 times bigger than A4)*/
}
.ch_cross {
position: absolute;
background-color: white;
height: 8.75mm; /* 7 * 1.25 */
width: 8.75mm; /* 7 * 1.25 */
top: 44.375mm; /* (16 + 23 - 7/2) * 1.25 = 41.5 * 1.25 */
left: 30.625mm; /* (5 + 23 - 7/2) * 1.25 = 24.5 * 1.25 */
/*These measures are multiplied by 1.25 here to fit the canvas size used by our reporting engine (1.25 times bigger than A4)*/
}
.swissqr_text {
font-family: Arial, Frutiger, Helvetica;
color: black;
line-height: 1;
padding-top: 1em;
top: 192mm * $ratio;
left: 62mm * $ratio;
width: 148mm * $ratio;
height: 105mm * $ratio - $rounding_offset;
border: 0.75pt * $ratio dashed black;
padding: 5mm * $ratio;
.title {
font-size: 8pt;
font-weight: bold;
margin-top: 2mm;
font-size: 8pt * $ratio;
line-height: 11pt * $ratio;
}
.content {
font-size: 10pt;
font-size: 10pt * $ratio;
line-height: 11pt * $ratio;
}
}
.main_title {
margin-top: 5mm;
font-size: 11pt;
font-weight: bold;
}
.swissqr_column_left {
position: absolute;
left: 5mm;
}
.swissqr_column_right {
position: absolute;
left: 70mm; /* (5 + 46 + 5) * 1.25 */
max-width: 90mm;
}
.procedure_zone {
top: 15mm;
}
.receipt_indication_zone {
top: 10mm;
}
.indication_zone {
top: 10mm;
}
.receipt_amount_zone {
position: absolute;
top: 86mm;
.column {
margin-right: 5mm;
.swissqr_column_left {
float: left;
width: $left_col_width;
.swissqr_section_title{
height: 7mm * $ratio;
}
.swissqr {
margin-top: 5mm * $ratio;
margin-bottom: 5mm * $ratio;
height: 46mm * $ratio;
width: 46mm * $ratio;
}
.amount_zone {
width: $left_col_width;
height: 22mm * $ratio;
.column {
margin-right: 3mm;
float: left;
}
.title {
font-size: 8pt * $ratio;
line-height: 11pt * $ratio;
}
.content {
font-size: 10pt * $ratio;
line-height: 13pt * $ratio;
}
}
}
}
.receipt_acceptance_point_zone {
position: relative;
top: 100mm;
.content {
.swissqr_column_right {
float: right;
padding-right: 1em;
width: $right_col_width;
}
}
.amount_zone {
.scissors {
width: 16px;
height: 16px;
}
.vertical_scissors {
position: absolute;
top: 86mm;
.column {
margin-right: 5mm;
float: left;
}
top: 5mm * $ratio;
left: -1.8mm * $ratio;
}
.horizontal_scissors {
position: absolute;
top: -2mm * $ratio;
left: 6mm * $ratio;
}
}