From 3230ae6441ddd502bbf8ccea6313137669aaa31a Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Tue, 16 Jun 2020 12:12:50 +0000 Subject: [PATCH] [FIX] l10n_ch - Swiss QR layout cleaning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This intend to enforce specifications and improve readability Layout changes: * [FIX] Amount section must be placed under the QR code * [FIX] Don't display empty additional information * [FIX] Rename slip sections and labels * [IMP] Rework of the layout Group content like adresse by removing line spacing Reduce character size to follow Swiss Implementation Guidelines QR-bill v2.1 Reduce left margin to avoid overlap of spaced ISR reference on the Receipt * [FIX] Missing street on Receipt * [FIX] Add thousand separators Official specs asks for: - thousand separators as blank. (using a non breaking to avoid spliting the amount) - decimal separators as a full stop > If the amount isincluded in the Swiss QR Code, then it must be printed after the currency code. A blank (space) should be used as the thousands separator and a full stop «.»as the decimal separator. The amount must always include two decimal places (e.g. CHF 1 590.00). QR-Code: * [IMP] Align QR code upper and improve accuracy of size Add an option on reportlab to print QR Code without surounding blank space this is required to compute with accuracy the width of 46mm x 46mm defined in the specs. * [FIX] Street and street2 issues Removes an extra space between street values when only one is given. Test the right partner street, only the company street was checked. QRR generation * [FIX] make it possible to generate QRR It must be possible to generate QRR without ISR subscription number. Content removed as not present in the specs version 2.1: * [RM] procedure section * [RM] due date Translations: * [IMP] Add translations of the QR-bill in DE, FR and IT * [FIX] QR-bill lang is now based on customer lang Tests: * [IMP] Add unit tests for Swiss reality check for the QR-bill closes odoo/odoo#54053 X-original-commit: 4f4edd0594b29252a5d44281cc773230c09521e9 Signed-off-by: oco-odoo --- addons/l10n_ch/i18n/l10n_ch.pot | 115 +++--------- addons/l10n_ch/i18n_extra/de.po | 84 +++------ addons/l10n_ch/i18n_extra/fr.po | 78 ++++++++ addons/l10n_ch/i18n_extra/it.po | 108 +++-------- addons/l10n_ch/i18n_extra/l10n_ch.pot | 56 ++---- addons/l10n_ch/models/account_invoice.py | 10 +- addons/l10n_ch/models/res_bank.py | 19 +- addons/l10n_ch/report/swissqr_report.xml | 171 ++++++++++------- .../static/src/scss/report_swissqr.scss | 97 ++++++---- addons/l10n_ch/tests/__init__.py | 1 + addons/l10n_ch/tests/test_swissqr.py | 177 ++++++++++++++++++ odoo/addons/base/models/ir_actions_report.py | 8 +- 12 files changed, 530 insertions(+), 394 deletions(-) create mode 100644 addons/l10n_ch/i18n_extra/fr.po create mode 100644 addons/l10n_ch/tests/test_swissqr.py diff --git a/addons/l10n_ch/i18n/l10n_ch.pot b/addons/l10n_ch/i18n/l10n_ch.pot index 6ae9356b26e..9271c1cd9b5 100644 --- a/addons/l10n_ch/i18n/l10n_ch.pot +++ b/addons/l10n_ch/i18n/l10n_ch.pot @@ -142,38 +142,6 @@ msgstr "" msgid "910 Les dons, les dividendes, les dédommagements, ..." msgstr "" -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"
\n" -"\n" -" Creditor
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"
\n" -"\n" -" Debtor
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"
\n" -"\n" -" Due date
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"
\n" -"\n" -" Reference number
" -msgstr "" - #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.res_config_settings_view_form msgid "ISR scan line offset" @@ -181,53 +149,52 @@ msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"QR-bill payment " -"part
" +msgid "Acceptance point" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Account
" +msgid "Additional information
" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Additional information
" +msgid "Amount
" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Amount
" +msgid "Account / Payable to
" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Currency
" +msgid "Currency
" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"Supports
\n" -" Credit transfer" +msgid "Payable by
" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"Some pieces of this information are not set correctly to display the Swiss QR Code.
\n" -" -Bank > CHF ISR subscription
\n" -" -Bank > EUR ISR subscription
\n" -" -Your company > Street with number
\n" -" -Your company > City
\n" -" -Your company > Zip
\n" -" -Your company > Country
\n" -" -Debtor > Street with number
\n" -" -Debtor > City
\n" -" -Debtor > Zip
\n" -" -Debtor > Country\n" -"
" +msgid "Payable to
" +msgstr "" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "Reference
" +msgstr "" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "Payment Part" +msgstr "" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "Receipt" msgstr "" #. module: l10n_ch @@ -601,41 +568,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template msgid "QR-bill for invoice" msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "QR-bill Payment Receipt Part
\n" -"\n" -" Payable to
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Payable to
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "
\n" -"\n" -" Reference
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Payable by
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Payable by
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Acceptance point" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "QR-bill Payment Part
" diff --git a/addons/l10n_ch/i18n_extra/de.po b/addons/l10n_ch/i18n_extra/de.po index 257243f27cf..4def08bbd75 100644 --- a/addons/l10n_ch/i18n_extra/de.po +++ b/addons/l10n_ch/i18n_extra/de.po @@ -7,8 +7,8 @@ msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-28 09:52+0000\n" -"PO-Revision-Date: 2019-02-12 12:06+0530\n" -"Last-Translator: didier.donze@camptocamp.com\n" +"PO-Revision-Date: 2020-06-17 10:00+0000\n" +"Last-Translator: yannick.vaucher@camptocamp.com\n" "Language-Team: \n" "Language: de\n" "MIME-Version: 1.0\n" @@ -25,7 +25,7 @@ msgstr "" #. module: l10n_ch #: model:ir.actions.report,print_report_name:l10n_ch.l10n_ch_qr_report msgid "'QR-bill-%s' % object.name" -msgstr "" +msgstr "'QR-Rechnung-%s' % object.name" #. module: l10n_ch #: model:account.tax.template,description:l10n_ch.vat_other_movements_910 @@ -328,90 +328,48 @@ msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"
\n" -"\n" -" Due date
" -msgstr "" +msgid "Acceptance point" +msgstr "Annahmestelle" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"
\n" -"\n" -" Payable by
" -msgstr "" +msgid "Account / Payable to
" +msgstr "Konto / Zahlbar an
" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"
\n" -"\n" -" Reference
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.res_config_settings_view_form -msgid "ISR scan line offset" -msgstr "" +msgid "Additional information
" +msgstr "Zusätzliche Informationen
" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"QR-bill Payment Part
" -msgstr "" +msgid "Amount
" +msgstr "Betrag
" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"QR-bill Payment Receipt Part
\n" -"\n" -" Payable to
" -msgstr "" +msgid "Currency
" +msgstr "Währung
" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Acceptance point" -msgstr "" +msgid "Payable by
" +msgstr "Zahlbar durch
" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Additional information
" -msgstr "" +msgid "Reference
" +msgstr "Referenz
" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Amount
" -msgstr "" +msgid "Payment Part" +msgstr "Zahlteil" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Currency
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Payable by
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Payable to
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"Supports
\n" -" Credit " -"transfer" -msgstr "" +msgid "Receipt" +msgstr "Empfangsschein" #. module: l10n_ch #: model:account.tax.report.line,name:l10n_ch.account_tax_report_line_chtax_autres_mouv diff --git a/addons/l10n_ch/i18n_extra/fr.po b/addons/l10n_ch/i18n_extra/fr.po new file mode 100644 index 00000000000..55f97427b05 --- /dev/null +++ b/addons/l10n_ch/i18n_extra/fr.po @@ -0,0 +1,78 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_ch +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-05-28 09:52+0000\n" +"PO-Revision-Date: 2020-06-17 10:00+0000\n" +"Last-Translator: yannick.vaucher@camptocamp.com\n" +"Language-Team: \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 2.2.1\n" + +#. module: l10n_ch +#: model:ir.actions.report,print_report_name:l10n_ch.l10n_ch_qr_report +msgid "'QR-bill-%s' % object.name" +msgstr "'QR-facture-%s' % object.name" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "QR-bill for invoice" +msgstr "QR-facture" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.isr_invoice_form +msgid "Print QR-bill" +msgstr "Imprimer QR-facture" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "Acceptance point" +msgstr "Point de dépôt" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "Account / Payable to
" +msgstr "Compte / Payable à
" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "Additional information
" +msgstr "Information supplémentaires
" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "Amount
" +msgstr "Montant
" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "Currency
" +msgstr "Monnaie
" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "Payable by
" +msgstr "Payable par
" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "Reference
" +msgstr "Référence
" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "Payment Part" +msgstr "Section paiement" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "Receipt" +msgstr "Récépissé" diff --git a/addons/l10n_ch/i18n_extra/it.po b/addons/l10n_ch/i18n_extra/it.po index 2f8b5dbfeab..92e0e32d7c9 100644 --- a/addons/l10n_ch/i18n_extra/it.po +++ b/addons/l10n_ch/i18n_extra/it.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-28 09:52+0000\n" -"PO-Revision-Date: 2020-05-28 14:49+0200\n" +"PO-Revision-Date: 2020-06-17 10:00+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "Language: it\n" @@ -328,113 +328,48 @@ msgstr "910 Donazioni, dividendi, compensi, ..." #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"
\n" -"\n" -" Due date
" -msgstr "" -"
\n" -"\n" -" Data di " -"scadenza
" +msgid "Acceptance point" +msgstr "Punto di accettazione" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"
\n" -"\n" -" Payable by
" -msgstr "" -"
\n" -"\n" -" Pagabile da
" +msgid "Account / Payable to
" +msgstr "Conto / Pagabile a
" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"
\n" -"\n" -" Reference
" -msgstr "" -"
\n" -"\n" -" Riferimento
" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.res_config_settings_view_form -msgid "ISR scan line offset" -msgstr "" -"Offset della linea di scansione SRI" +msgid "Additional information
" +msgstr "Informationi supplementari
" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"QR-bill Payment Part
" -msgstr "" -"Parte di pagamento QR-fattura
" +msgid "Amount
" +msgstr "Importo
" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"QR-bill Payment Receipt Part
\n" -"\n" -" Payable to
" -msgstr "" -"QR-fattura Parte Ricevuta di " -"pagamento
\n" -"\n" -" Pagabile a
" +msgid "Currency
" +msgstr "Valuta
" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Acceptance point" -msgstr "Punto di accettazione" +msgid "Payable by
" +msgstr "Pagabile da
" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Additional information
" -msgstr "Ulteriori informazioni
" +msgid "Reference
" +msgstr "Riferimento
" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Amount
" -msgstr "Importo
" +msgid "Payment Part" +msgstr "Sezione pagamento" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Currency
" -msgstr "Valuta
" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Payable by
" -msgstr "Pagabile da
" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Payable to
" -msgstr "Pagabile a
" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"Supports
\n" -" Credit " -"transfer" -msgstr "" -"Supporta
\n" -" Bonifico " -"bancario" +msgid "Receipt" +msgstr "Ricevuta" #. module: l10n_ch #: model:account.tax.report.line,name:l10n_ch.account_tax_report_line_chtax_autres_mouv @@ -1431,6 +1366,11 @@ msgstr "QR-fattura" msgid "QR-bill for invoice" msgstr "QR per fattura" +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "QR-bill for invoice" +msgstr "QR-facture" + #. module: l10n_ch #: model:account.account.template,name:l10n_ch.ch_coa_3801 msgid "Rabais et réduction de prix" diff --git a/addons/l10n_ch/i18n_extra/l10n_ch.pot b/addons/l10n_ch/i18n_extra/l10n_ch.pot index f6811c3797b..8cff14a83ca 100644 --- a/addons/l10n_ch/i18n_extra/l10n_ch.pot +++ b/addons/l10n_ch/i18n_extra/l10n_ch.pot @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-28 09:52+0000\n" -"PO-Revision-Date: 2020-05-28 09:52+0000\n" +"PO-Revision-Date: 2020-06-17 10:00+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -324,30 +324,6 @@ msgstr "" msgid "910 Les dons, les dividendes, les dédommagements, ..." msgstr "" -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"
\n" -"\n" -" Due date
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"
\n" -"\n" -" Payable by
" -msgstr "" - -#. module: l10n_ch -#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"
\n" -"\n" -" Reference
" -msgstr "" - #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.res_config_settings_view_form msgid "ISR scan line offset" @@ -355,54 +331,52 @@ msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"QR-bill Payment " -"Part
" +msgid "Acceptance point" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"QR-bill Payment Receipt Part
\n" -"\n" -" Payable to
" +msgid "Additional information
" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Acceptance point" +msgid "Amount
" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Additional information
" +msgid "Account / Payable to
" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Amount
" +msgid "Currency
" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Currency
" +msgid "Payable by
" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Payable by
" +msgid "Payable to
" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Payable to
" +msgid "Reference
" msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "" -"Supports
\n" -" Credit transfer" +msgid "Payment Part" +msgstr "" + +#. module: l10n_ch +#: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template +msgid "Receipt" msgstr "" #. module: l10n_ch diff --git a/addons/l10n_ch/models/account_invoice.py b/addons/l10n_ch/models/account_invoice.py index 5799f41384f..3ed18cbad8a 100644 --- a/addons/l10n_ch/models/account_invoice.py +++ b/addons/l10n_ch/models/account_invoice.py @@ -60,9 +60,9 @@ class AccountMove(models.Model): record.l10n_ch_isr_subscription = _format_isr_subscription_scanline(isr_subscription) record.l10n_ch_isr_subscription_formatted = _format_isr_subscription(isr_subscription) - @api.depends('name', 'partner_bank_id.l10n_ch_postal') + @api.depends('name', 'partner_bank_id.l10n_ch_postal', 'partner_bank_id.acc_number') def _compute_l10n_ch_isr_number(self): - """ The ISR reference number is 27 characters long. The first 12 of them + """ The QRR or ISR reference number is 27 characters long. The first 12 of them contain the postal account number of this ISR's issuer, removing the zeros at the beginning and filling the empty places with zeros on the right if it is too short. The next 14 characters contain an internal reference identifying @@ -72,8 +72,10 @@ class AccountMove(models.Model): of a recursive modulo 10 on its first 26 characters. """ for record in self: - if record.name and record.partner_bank_id and record.partner_bank_id.l10n_ch_postal: - invoice_issuer_ref = record.partner_bank_id.l10n_ch_postal.ljust(l10n_ch_ISR_NUMBER_ISSUER_LENGTH, '0') + has_qriban = record.partner_bank_id._is_qr_iban() + isr_subscription = record.partner_bank_id.l10n_ch_postal + if (has_qriban or isr_subscription) and record.name: + invoice_issuer_ref = (isr_subscription or '').ljust(l10n_ch_ISR_NUMBER_ISSUER_LENGTH, '0') invoice_ref = re.sub('[^\d]', '', record.name) #We only keep the last digits of the sequence number if it is too long invoice_ref = invoice_ref[-l10n_ch_ISR_NUMBER_ISSUER_LENGTH:] diff --git a/addons/l10n_ch/models/res_bank.py b/addons/l10n_ch/models/res_bank.py index d01c7a875e9..779acdc331a 100644 --- a/addons/l10n_ch/models/res_bank.py +++ b/addons/l10n_ch/models/res_bank.py @@ -103,7 +103,7 @@ class ResPartnerBank(models.Model): if qr_method == 'ch_qr': qr_code_vals = self._l10n_ch_get_qr_vals(amount, currency, debtor_partner, free_communication, structured_communication) - return '/report/barcode/?type=%s&value=%s&width=%s&height=%s&humanreadable=1&mask=ch_cross' % ('QR', werkzeug.urls.url_quote_plus('\n'.join(qr_code_vals)), 256, 256) + return '/report/barcode/?type=%s&value=%s&width=%s&height=%s&quiet=1&mask=ch_cross' % ('QR', werkzeug.urls.url_quote_plus('\n'.join(qr_code_vals)), 256, 256) return super()._get_qr_code_url(qr_method, amount, currency, debtor_partner, free_communication, structured_communication) @@ -161,12 +161,27 @@ class ResPartnerBank(models.Model): 'EPD', # Mandatory trailer part ] + def _get_partner_address_lines(self, partner): + """ Returns a tuple of two elements containing the address lines to use + for this partner. Line 1 contains the street and number, line 2 contains + zip and city. Those two lines are limited to 70 characters + """ + streets = [partner.street, partner.street2] + line_1 = ' '.join(filter(None, streets)) + line_2 = partner.zip + ' ' + partner.city + return line_1[:70], line_2[:70] + def _is_qr_iban(self): """ Tells whether or not this bank account has a QR-IBAN account number. QR-IBANs are specific identifiers used in Switzerland as references in QR-codes. They are formed like regular IBANs, but are actually something different. """ + # for conveniance when invoice.partner_bank_id, could be replaced + # by a computed field + if not self: + return False + self.ensure_one() iid_start_index = 4 @@ -210,7 +225,7 @@ class ResPartnerBank(models.Model): return partner.zip and \ partner.city and \ partner.country_id.code and \ - (self.partner_id.street or self.partner_id.street2) + (partner.street or partner.street2) if qr_method == 'ch_qr': if not _partner_fields_set(self.partner_id): diff --git a/addons/l10n_ch/report/swissqr_report.xml b/addons/l10n_ch/report/swissqr_report.xml index 8df6286e2a3..69c149c6f25 100644 --- a/addons/l10n_ch/report/swissqr_report.xml +++ b/addons/l10n_ch/report/swissqr_report.xml @@ -20,100 +20,127 @@