[FIX] account_qr_code_emv: fallback error
The account_qr_code_emv module has an issue at the
moment where it will only return errors in
_get_error_messages_for_qr for the country the qr
code is intended for.
This makes sense since you want to check all countries
in later versions where we have multiple of them.
But it causes an issue with the standard implementation
where if you are using a country that is not supported
by an EMV QR, _get_error_messages_for_qr will just
return None.
This means that:
- The default QR CODE selection on the invoice that
depends on that may select EMV QR for unrelated
countries.
- If it gets selected, this method will not check
that the currency is correct for said countries.
To fix this issue, we will simply return an error
message in the common module, which will serve as a
fallback once all the EMV QR methods have been checked.
Task id # 3758668
closes odoo/odoo#156847
X-original-commit: 5290fb7a2d400ce1c9732e8d835f6b7990c0d145
Signed-off-by: de Wouters de Bouchout Jean-Benoît (jbw) <jbw@odoo.com>
Signed-off-by: Nicolas Viseur (vin) <vin@odoo.com>
This commit is contained in:
@@ -84,6 +84,13 @@ msgstr ""
|
||||
msgid "Missing Proxy Value."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_qr_code_emv
|
||||
#. odoo-python
|
||||
#: code:addons/account_qr_code_emv/models/res_bank.py:0
|
||||
#, python-format
|
||||
msgid "No EMV QR Code is available for the country of the account %(account_number)s."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_qr_code_emv
|
||||
#: model:ir.model.fields.selection,name:account_qr_code_emv.selection__res_partner_bank__proxy_type__none
|
||||
msgid "None"
|
||||
|
||||
@@ -111,3 +111,10 @@ class ResPartnerBank(models.Model):
|
||||
rslt = super()._get_available_qr_methods()
|
||||
rslt.append(('emv_qr', _("EMV Merchant-Presented QR-code"), 30))
|
||||
return rslt
|
||||
|
||||
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':
|
||||
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)
|
||||
|
||||
@@ -106,3 +106,17 @@ class TestL10nHKEmvQrCode(AccountTestInvoicingCommon):
|
||||
|
||||
# Check the whole qr code string
|
||||
self.assertEqual(emv_qr_vals, '00020101021226330012hk.com.hkicl0313+852-678912345204000053033445405100.55802HK5914company_1_data6002HK62170513INV/TEST/000263049E64')
|
||||
|
||||
def test_invoice_default_code(self):
|
||||
""" If no QR method is selected by default, and the country does not match, it should not be selecting the EMV QR method. """
|
||||
self.acc_emv_hk.country_code = 'NZ'
|
||||
|
||||
self.assertIsNone(self.emv_qr_invoice._generate_qr_code())
|
||||
|
||||
def test_invoice_wrong_method(self):
|
||||
""" If an EMV QR is selected on the invoice with a wrong country, it should raise errors messages. """
|
||||
self.acc_emv_hk.country_code = 'NZ'
|
||||
self.emv_qr_invoice.qr_code_method = 'emv_qr'
|
||||
|
||||
error_message = self.acc_emv_hk._get_error_messages_for_qr('emv_qr', self.partner_a, self.env.ref('base.HKD'))
|
||||
self.assertIsNotNone(error_message)
|
||||
|
||||
Reference in New Issue
Block a user