From 39df0141b90d69fffa93cc9b1a74b7d73be7d3d2 Mon Sep 17 00:00:00 2001 From: mhch-odoo Date: Tue, 16 Apr 2024 16:20:42 +0800 Subject: [PATCH] [FIX] account_qr_code_emv: Improve Fallback error At the moment, if EMV QR is selected on the invoice where the country does not support EMV QR an error is raised. However, this error is also raised if EMV QR is selected but the bank account is not set. The following error is raise `No EMV QR Code is available for the country of the account False.` This commit adds a check to ensure the bank account is set and raise a better error message. Task# 3868467 closes odoo/odoo#162500 X-original-commit: e6ca281b691e75dd9c12fb110f80f444c21729de Signed-off-by: Nicolas Viseur (vin) --- addons/account_qr_code_emv/i18n/account_qr_code_emv.pot | 7 +++++++ addons/account_qr_code_emv/models/res_bank.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/addons/account_qr_code_emv/i18n/account_qr_code_emv.pot b/addons/account_qr_code_emv/i18n/account_qr_code_emv.pot index 7a76891a9a7..3e6a199205d 100644 --- a/addons/account_qr_code_emv/i18n/account_qr_code_emv.pot +++ b/addons/account_qr_code_emv/i18n/account_qr_code_emv.pot @@ -15,6 +15,13 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: account_qr_code_emv +#. odoo-python +#: code:addons/account_qr_code_emv/models/res_bank.py:0 +#, python-format +msgid "A bank account is required for EMV QR Code generation." +msgstr "" + #. module: account_qr_code_emv #: model:ir.model,name:account_qr_code_emv.model_res_partner_bank msgid "Bank Accounts" diff --git a/addons/account_qr_code_emv/models/res_bank.py b/addons/account_qr_code_emv/models/res_bank.py index bedf8525362..321e2786dfd 100644 --- a/addons/account_qr_code_emv/models/res_bank.py +++ b/addons/account_qr_code_emv/models/res_bank.py @@ -115,6 +115,8 @@ class ResPartnerBank(models.Model): def _get_error_messages_for_qr(self, qr_method, debtor_partner, currency): """ Return an error for emv_qr if the account's country does no match any methods found in inheriting modules.""" if qr_method == 'emv_qr': + if not self: + return _("A bank account is required for EMV QR Code generation.") return _("No EMV QR Code is available for the country of the account %(account_number)s.", account_number=self.acc_number) return super()._get_error_messages_for_qr(qr_method, debtor_partner, currency)