details:   https://code.tryton.org/tryton/commit/84ec265a540c
branch:    7.6
user:      Cédric Krier <[email protected]>
date:      Wed Apr 08 18:49:25 2026 +0200
description:
        Remove invalid SEPA mandate when payment is reset to draft

        Closes #14756
        (grafted from b7ab57a8f93db47a432e33e4fbf5959fc3912c34)
diffstat:

 modules/account_payment_sepa/payment.py |  13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diffs (23 lines):

diff -r 45b72017d9cc -r 84ec265a540c modules/account_payment_sepa/payment.py
--- a/modules/account_payment_sepa/payment.py   Thu Apr 16 23:29:17 2026 +0200
+++ b/modules/account_payment_sepa/payment.py   Wed Apr 08 18:49:25 2026 +0200
@@ -490,6 +490,19 @@
             ('sepa_info_id', operator, code_value, *extra),
             ]
 
+    @classmethod
+    @ModelView.button
+    @Workflow.transition('draft')
+    def draft(cls, payments):
+        to_remove_mandate = []
+        for payment in payments:
+            if (payment.sepa_mandate
+                    and payment.sepa_mandate.state != 'validated'):
+                to_remove_mandate.append(payment)
+        if to_remove_mandate:
+            cls.write(to_remove_mandate, {'sepa_mandate': None})
+        super().draft(payments)
+
 
 class Mandate(Workflow, ModelSQL, ModelView):
     __name__ = 'account.payment.sepa.mandate'

Reply via email to