[REF] Account Banking Pain Base: constraint on BIC

Prevent inserting BIC not respecting the SEPA pain schemas.
This commit is contained in:
Thomas Binsfeld
2019-02-27 10:09:12 +01:00
committed by Pedro M. Baeza
parent 269c36df85
commit c712fdb819
12 changed files with 183 additions and 0 deletions

View File

@@ -53,6 +53,11 @@ msgstr ""
msgid "Annuity"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_res_bank
msgid "Bank"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_bank_payment_line
msgid "Bank Payment Lines"
@@ -768,6 +773,15 @@ msgstr ""
msgid "The '%s' is empty or 0. It should have a non-null value."
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/res_bank.py:27
#, python-format
msgid "The following Bank Identifier Codes (BIC) do not respect the SEPA pattern:\n"
"{bic_list}\n"
"\n"
"SEPA pattern: {sepa_pattern}"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/account_payment_order.py:138
#, python-format

View File

@@ -63,6 +63,11 @@ msgstr ""
msgid "Annuity"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_res_bank
msgid "Bank"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_bank_payment_line
msgid "Bank Payment Lines"
@@ -834,6 +839,16 @@ msgstr ""
msgid "The '%s' is empty or 0. It should have a non-null value."
msgstr "Das '%s' ist leer oder 0. Es sollte einen Nicht-Null-Wert haben."
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/res_bank.py:27
#, python-format
msgid ""
"The following Bank Identifier Codes (BIC) do not respect the SEPA pattern:\n"
"{bic_list}\n"
"\n"
"SEPA pattern: {sepa_pattern}"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/account_payment_order.py:138
#, python-format

View File

@@ -62,6 +62,11 @@ msgstr ""
msgid "Annuity"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_res_bank
msgid "Bank"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_bank_payment_line
msgid "Bank Payment Lines"
@@ -818,6 +823,16 @@ msgstr ""
msgid "The '%s' is empty or 0. It should have a non-null value."
msgstr "'%s' está vacío o es 0. Debería tener un valor no nulo."
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/res_bank.py:27
#, python-format
msgid ""
"The following Bank Identifier Codes (BIC) do not respect the SEPA pattern:\n"
"{bic_list}\n"
"\n"
"SEPA pattern: {sepa_pattern}"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/account_payment_order.py:138
#, python-format

View File

@@ -62,6 +62,11 @@ msgstr ""
msgid "Annuity"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_res_bank
msgid "Bank"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_bank_payment_line
msgid "Bank Payment Lines"
@@ -802,6 +807,16 @@ msgstr ""
msgid "The '%s' is empty or 0. It should have a non-null value."
msgstr "Le '%s' est vide ou égal à 0. Il devrait avoir une valeur non-nulle."
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/res_bank.py:27
#, python-format
msgid ""
"The following Bank Identifier Codes (BIC) do not respect the SEPA pattern:\n"
"{bic_list}\n"
"\n"
"SEPA pattern: {sepa_pattern}"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/account_payment_order.py:138
#, python-format

View File

@@ -63,6 +63,11 @@ msgstr ""
msgid "Annuity"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_res_bank
msgid "Bank"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_bank_payment_line
msgid "Bank Payment Lines"
@@ -807,6 +812,16 @@ msgstr ""
msgid "The '%s' is empty or 0. It should have a non-null value."
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/res_bank.py:27
#, python-format
msgid ""
"The following Bank Identifier Codes (BIC) do not respect the SEPA pattern:\n"
"{bic_list}\n"
"\n"
"SEPA pattern: {sepa_pattern}"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/account_payment_order.py:138
#, python-format

View File

@@ -60,6 +60,11 @@ msgstr ""
msgid "Annuity"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_res_bank
msgid "Bank"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_bank_payment_line
msgid "Bank Payment Lines"
@@ -801,6 +806,16 @@ msgstr ""
msgid "The '%s' is empty or 0. It should have a non-null value."
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/res_bank.py:27
#, python-format
msgid ""
"The following Bank Identifier Codes (BIC) do not respect the SEPA pattern:\n"
"{bic_list}\n"
"\n"
"SEPA pattern: {sepa_pattern}"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/account_payment_order.py:138
#, python-format

View File

@@ -63,6 +63,11 @@ msgstr ""
msgid "Annuity"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_res_bank
msgid "Bank"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_bank_payment_line
msgid "Bank Payment Lines"
@@ -805,6 +810,16 @@ msgstr ""
msgid "The '%s' is empty or 0. It should have a non-null value."
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/res_bank.py:27
#, python-format
msgid ""
"The following Bank Identifier Codes (BIC) do not respect the SEPA pattern:\n"
"{bic_list}\n"
"\n"
"SEPA pattern: {sepa_pattern}"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/account_payment_order.py:138
#, python-format

View File

@@ -62,6 +62,11 @@ msgstr ""
msgid "Annuity"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_res_bank
msgid "Bank"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_bank_payment_line
msgid "Bank Payment Lines"
@@ -815,6 +820,16 @@ msgstr ""
msgid "The '%s' is empty or 0. It should have a non-null value."
msgstr "De '%s' is leeg of 0. Deze waarde zou niet nul moeten zijn."
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/res_bank.py:27
#, python-format
msgid ""
"The following Bank Identifier Codes (BIC) do not respect the SEPA pattern:\n"
"{bic_list}\n"
"\n"
"SEPA pattern: {sepa_pattern}"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/account_payment_order.py:138
#, python-format

View File

@@ -62,6 +62,11 @@ msgstr ""
msgid "Annuity"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_res_bank
msgid "Bank"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_bank_payment_line
msgid "Bank Payment Lines"
@@ -799,6 +804,16 @@ msgstr ""
msgid "The '%s' is empty or 0. It should have a non-null value."
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/res_bank.py:27
#, python-format
msgid ""
"The following Bank Identifier Codes (BIC) do not respect the SEPA pattern:\n"
"{bic_list}\n"
"\n"
"SEPA pattern: {sepa_pattern}"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/account_payment_order.py:138
#, python-format

View File

@@ -62,6 +62,11 @@ msgstr ""
msgid "Annuity"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_res_bank
msgid "Bank"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_bank_payment_line
msgid "Bank Payment Lines"
@@ -801,6 +806,16 @@ msgstr ""
msgid "The '%s' is empty or 0. It should have a non-null value."
msgstr "'%s' je prazno ali 0. Vsebovati bi moralo ne ničelno vrednost."
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/res_bank.py:27
#, python-format
msgid ""
"The following Bank Identifier Codes (BIC) do not respect the SEPA pattern:\n"
"{bic_list}\n"
"\n"
"SEPA pattern: {sepa_pattern}"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/models/account_payment_order.py:138
#, python-format

View File

@@ -5,3 +5,4 @@ from . import account_payment_mode
from . import res_company
from . import res_config_settings
from . import account_payment_method
from . import res_bank

View File

@@ -0,0 +1,33 @@
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import re
from odoo import api, models, _
from odoo.exceptions import ValidationError
BIC_REGEX = re.compile(r"[A-Z]{6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3})?$")
class ResBank(models.Model):
_inherit = 'res.bank'
@api.multi
@api.constrains('bic')
def _check_bic(self):
"""
This method strengthens the constraint on the BIC of the bank account
(The account_payment_order module already checks the length in the
check_bic_length method).
:raise: ValidationError if the BIC doesn't respect the regex of the
SEPA pain schemas.
"""
invalid_banks = self.filtered(lambda r: not BIC_REGEX.match(r.bic))
if invalid_banks:
raise ValidationError(_(
"The following Bank Identifier Codes (BIC) do not respect "
"the SEPA pattern:\n{bic_list}\n\nSEPA pattern: "
"{sepa_pattern}").format(
sepa_pattern=BIC_REGEX.pattern,
bic_list="\n".join(invalid_banks.mapped('bic'))
))