From ce4d5c853939b2618254db262b7cd3078bee40fb Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 27 Sep 2023 22:30:31 +0200 Subject: [PATCH] Add warning when payment order is not SEPA The field 'sepa' on account.payment.order is only display for SEPA payment methods. If the option "show warning if not SEPA" is enabled on the payment method, a warning banner is now displayed on payment orders with a SEPA payment method which are not SEPA. --- account_banking_sepa_credit_transfer/__manifest__.py | 2 +- .../data/account_payment_method.xml | 1 + .../migrations/16.0.1.0.1/post-migration.py | 11 +++++++++++ .../tests/test_sct.py | 5 ++++- 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 account_banking_sepa_credit_transfer/migrations/16.0.1.0.1/post-migration.py diff --git a/account_banking_sepa_credit_transfer/__manifest__.py b/account_banking_sepa_credit_transfer/__manifest__.py index 9db14fd68..6b173e9da 100644 --- a/account_banking_sepa_credit_transfer/__manifest__.py +++ b/account_banking_sepa_credit_transfer/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Account Banking SEPA Credit Transfer", "summary": "Create SEPA XML files for Credit Transfers", - "version": "16.0.1.0.0", + "version": "16.0.1.0.1", "license": "AGPL-3", "author": "Akretion, Tecnativa, Odoo Community Association (OCA)", "website": "https://github.com/OCA/bank-payment", diff --git a/account_banking_sepa_credit_transfer/data/account_payment_method.xml b/account_banking_sepa_credit_transfer/data/account_payment_method.xml index 01b08910a..2d16c170a 100644 --- a/account_banking_sepa_credit_transfer/data/account_payment_method.xml +++ b/account_banking_sepa_credit_transfer/data/account_payment_method.xml @@ -6,5 +6,6 @@ outbound pain.001.001.03 + diff --git a/account_banking_sepa_credit_transfer/migrations/16.0.1.0.1/post-migration.py b/account_banking_sepa_credit_transfer/migrations/16.0.1.0.1/post-migration.py new file mode 100644 index 000000000..c41e4b774 --- /dev/null +++ b/account_banking_sepa_credit_transfer/migrations/16.0.1.0.1/post-migration.py @@ -0,0 +1,11 @@ +# Copyright 2023 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + sct_method = env.ref("account_banking_sepa_credit_transfer.sepa_credit_transfer") + sct_method.write({"warn_not_sepa": True}) diff --git a/account_banking_sepa_credit_transfer/tests/test_sct.py b/account_banking_sepa_credit_transfer/tests/test_sct.py index 7873dcf80..2914e0e19 100644 --- a/account_banking_sepa_credit_transfer/tests/test_sct.py +++ b/account_banking_sepa_credit_transfer/tests/test_sct.py @@ -206,7 +206,10 @@ class TestSCT(TransactionCase): self.assertEqual(agrolait_pay_line1.communication, "F1341") self.payment_order.draft2open() self.assertEqual(self.payment_order.state, "open") - self.assertEqual(self.payment_order.sepa, True) + if self.payment_mode.payment_method_id.pain_version: + self.assertTrue(self.payment_order.sepa) + else: + self.assertFalse(self.payment_order.sepa) self.assertTrue(self.payment_order.payment_ids) agrolait_bank_line = self.payment_order.payment_ids[0] self.assertEqual(agrolait_bank_line.currency_id, self.eur_currency)