changeset af3d1b7a5b56 in modules/account_payment:default
details: 
https://hg.tryton.org/modules/account_payment?cmd=changeset;node=af3d1b7a5b56
description:
        Allow going back to processing state

        This allows to avoid to use the failed state when updating a succeeded 
payment
        as specific workflow may be plugged to the fail transition.

        issue9525
        review302001002
diffstat:

 CHANGELOG  |   1 +
 payment.py |  11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletions(-)

diffs (51 lines):

diff -r 60f04e96fd33 -r af3d1b7a5b56 CHANGELOG
--- a/CHANGELOG Sat Jul 25 08:04:41 2020 +0200
+++ b/CHANGELOG Sat Aug 29 18:17:51 2020 +0200
@@ -1,3 +1,4 @@
+* Allow going back to processing state
 * Add aggregated information on Payment groups
 
 Version 5.6.0 - 2020-05-04
diff -r 60f04e96fd33 -r af3d1b7a5b56 payment.py
--- a/payment.py        Sat Jul 25 08:04:41 2020 +0200
+++ b/payment.py        Sat Aug 29 18:17:51 2020 +0200
@@ -325,7 +325,9 @@
                 ('processing', 'failed'),
                 ('approved', 'draft'),
                 ('succeeded', 'failed'),
+                ('succeeded', 'processing'),
                 ('failed', 'succeeded'),
+                ('failed', 'processing'),
                 ))
         cls._buttons.update({
                 'draft': {
@@ -456,7 +458,6 @@
         pass
 
     @classmethod
-    @Workflow.transition('processing')
     def process(cls, payments, group):
         pool = Pool()
         Group = pool.get('account.payment.group')
@@ -465,6 +466,9 @@
             cls.write(payments, {
                     'group': group.id,
                     })
+            # Set state before calling process method
+            # as it may set a different state directly
+            cls.proceed(payments)
             process_method = getattr(Group,
                 'process_%s' % group.journal.process_method, None)
             if process_method:
@@ -473,6 +477,11 @@
             return group
 
     @classmethod
+    @Workflow.transition('processing')
+    def proceed(cls, payments):
+        assert all(p.group for p in payments)
+
+    @classmethod
     @ModelView.button
     @Workflow.transition('succeeded')
     def succeed(cls, payments):

Reply via email to