[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) <vin@odoo.com>
This commit is contained in:
mhch-odoo
2024-04-19 02:27:25 +00:00
parent 73627b45eb
commit 39df0141b9
2 changed files with 9 additions and 0 deletions
@@ -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"
@@ -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)