diff --git a/account_banking_pain_base/models/account_payment_order.py b/account_banking_pain_base/models/account_payment_order.py
index 9e35926e6..4d5da9800 100644
--- a/account_banking_pain_base/models/account_payment_order.py
+++ b/account_banking_pain_base/models/account_payment_order.py
@@ -58,17 +58,66 @@ class AccountPaymentOrder(models.Model):
"transfer of the SEPA XML file.",
)
+ @api.model
+ def _sepa_iban_prefix_list(self):
+ # List of IBAN prefixes (not country codes !)
+ # Source: https://www.europeanpaymentscouncil.eu/sites/default/files/kb/file/2020-10/EPC409-09%20EPC%20List%20of%20SEPA%20Scheme%20Countries%20v3.0_1.pdf # noqa: B950
+ # Some countries use IBAN but are not part of the SEPA zone
+ # example: Turkey, Madagascar, Tunisia, etc.
+ return [
+ "BE",
+ "BG",
+ "ES",
+ "HR",
+ "CY",
+ "CZ",
+ "DK",
+ "EE",
+ "FI",
+ "FR",
+ "DE",
+ "GI",
+ "GR",
+ "GB",
+ "HU",
+ "IS",
+ "IE",
+ "IT",
+ "LV",
+ "LI",
+ "LT",
+ "LU",
+ "PT",
+ "MT",
+ "MC",
+ "NL",
+ "NO",
+ "PL",
+ "RO",
+ "SM",
+ "SK",
+ "SI",
+ "SE",
+ "CH",
+ "VA",
+ ]
+
@api.depends(
"company_partner_bank_id.acc_type",
+ "company_partner_bank_id.sanitized_acc_number",
"payment_line_ids.currency_id",
"payment_line_ids.partner_bank_id.acc_type",
+ "payment_line_ids.partner_bank_id.sanitized_acc_number",
)
def _compute_sepa(self):
eur = self.env.ref("base.EUR")
+ sepa_list = self._sepa_iban_prefix_list()
for order in self:
sepa = True
if order.company_partner_bank_id.acc_type != "iban":
sepa = False
+ if order.company_partner_bank_id and order.company_partner_bank_id.sanitized_acc_number[:2] not in sepa_list:
+ sepa = False
for pline in order.payment_line_ids:
if pline.currency_id != eur:
sepa = False
@@ -76,6 +125,9 @@ class AccountPaymentOrder(models.Model):
if pline.partner_bank_id.acc_type != "iban":
sepa = False
break
+ if pline.partner_bank_id and pline.partner_bank_id.sanitized_acc_number[:2] not in sepa_list:
+ sepa = False
+ break
sepa = order.compute_sepa_final_hook(sepa)
self.sepa = sepa
diff --git a/account_banking_pain_base/views/account_payment_line.xml b/account_banking_pain_base/views/account_payment_line.xml
index e71be074a..4e3eecce7 100644
--- a/account_banking_pain_base/views/account_payment_line.xml
+++ b/account_banking_pain_base/views/account_payment_line.xml
@@ -20,4 +20,18 @@
+
+ pain.base.account.payment.tree
+ account.payment.line
+
+
+
+
+
+
+
+
diff --git a/account_banking_pain_base/views/account_payment_order.xml b/account_banking_pain_base/views/account_payment_order.xml
index 8188bf27d..b06fdcacb 100644
--- a/account_banking_pain_base/views/account_payment_order.xml
+++ b/account_banking_pain_base/views/account_payment_order.xml
@@ -21,5 +21,19 @@
/>
-
+
+
+ pain.base.account.payment.order.tree
+ account.payment.order
+
+
+
+
+
+
+
+
diff --git a/account_banking_pain_base/views/bank_payment_line_view.xml b/account_banking_pain_base/views/bank_payment_line_view.xml
index 1eb1e72d5..247de1783 100644
--- a/account_banking_pain_base/views/bank_payment_line_view.xml
+++ b/account_banking_pain_base/views/bank_payment_line_view.xml
@@ -17,4 +17,15 @@
+
+ pain.base.bank.payment.line.tree
+ bank.payment.line
+
+
+
+
+
+
+
+