From 68dafa0620fb8e36c9a1a58da0668bede2c3699b Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Mon, 22 Oct 2018 15:38:30 +0000 Subject: [PATCH] [FIX] l10n_ch: fix swiss QR Code crap The specifications of this feature have not been frozen yet and the feature is not expected before mid-2020. Merging it in stable was premature. There's now an ir.config.parameter to hide the feature until really needed: a field in the accounting settings will be added in a next version to show it, in the meanwhile people can manually add the parameter to use/test the QR code. Also fixed all 3 typos/grammar errors in the single sentence message displayed when some pieces of information were missing while printing the QR code Also fixed the place where the Swiss options for the ISR are displayed in the accounting settings (under 'invoices' instead of 'fiscal periods') Also fixed a 'not-a-multiple-of-4' indentation. closes odoo/odoo#28035 --- addons/l10n_ch/i18n/l10n_ch.pot | 2 +- addons/l10n_ch/models/account_invoice.py | 23 ++++++++++++------- addons/l10n_ch/report/swissqr_report.xml | 4 ++-- .../views/res_config_settings_views.xml | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/addons/l10n_ch/i18n/l10n_ch.pot b/addons/l10n_ch/i18n/l10n_ch.pot index 2035ed647d1..a5663c931cc 100644 --- a/addons/l10n_ch/i18n/l10n_ch.pot +++ b/addons/l10n_ch/i18n/l10n_ch.pot @@ -90,7 +90,7 @@ msgstr "" #. module: l10n_ch #: model_terms:ir.ui.view,arch_db:l10n_ch.l10n_ch_swissqr_template -msgid "Some of this informations are not set corrrectly to display the Swiss QR Code.
\n" +msgid "Some pieces of this information are not set correctly to display the Swiss QR Code.
\n" " -Bank > CHF ISR reference
\n" " -Bank > EUR ISR reference
\n" " -Your company > Street with number
\n" diff --git a/addons/l10n_ch/models/account_invoice.py b/addons/l10n_ch/models/account_invoice.py index 6373d00f8a7..8b402d14e99 100644 --- a/addons/l10n_ch/models/account_invoice.py +++ b/addons/l10n_ch/models/account_invoice.py @@ -133,15 +133,22 @@ class AccountInvoice(models.Model): record.l10n_ch_currency_name in ['EUR', 'CHF'] def split_total_amount(self): - """ Splits the total amount of this invoice in two parts, using the dot as - a separator, and taking two precision digits (always displayed). - These two parts are returned as the two elements of a tuple, as strings - to print in the report. + """ Splits the total amount of this invoice in two parts, using the dot as + a separator, and taking two precision digits (always displayed). + These two parts are returned as the two elements of a tuple, as strings + to print in the report. - This function is needed on the model, as it must be called in the report - template, which cannot reference static functions - """ - return float_split_str(self.amount_total, 2) + This function is needed on the model, as it must be called in the report + template, which cannot reference static functions + """ + return float_split_str(self.amount_total, 2) + + def display_swiss_qr_code(self): + """ Trigger the print of the Swiss QR code in the invoice report or not + """ + self.ensure_one() + qr_parameter = self.env['ir.config_parameter'].sudo().get_param('l10n_ch.print_qrcode') + return self.partner_id.country_id.code == 'CH' and qr_parameter def isr_print(self): """ Triggered by the 'Print ISR' button. diff --git a/addons/l10n_ch/report/swissqr_report.xml b/addons/l10n_ch/report/swissqr_report.xml index 37dc2b0f6b4..46ab9a8db26 100644 --- a/addons/l10n_ch/report/swissqr_report.xml +++ b/addons/l10n_ch/report/swissqr_report.xml @@ -4,7 +4,7 @@