From a1a08ef8d985d2eb0a142f5e4dae1af3e3c8dc23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 8 Apr 2026 18:49:25 +0200 Subject: [PATCH] Remove invalid SEPA mandate when payment is reset to draft Closes #14756 --- modules/account_payment_sepa/payment.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/account_payment_sepa/payment.py b/modules/account_payment_sepa/payment.py index 8365a117a2..7a2572fb45 100644 --- a/modules/account_payment_sepa/payment.py +++ b/modules/account_payment_sepa/payment.py @@ -489,6 +489,19 @@ class Payment(metaclass=PoolMeta): ('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 Payment_Invoice(metaclass=PoolMeta): __name__ = 'account.payment'