merge stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 08 Oct 2009 12:34:31 +0200
branchstable
changeset 3622 f4317edf4058
parent 3621 1ec4452aa36f (diff)
parent 3620 ec0be256882b (current diff)
child 3623 9b838e2d72bb
merge
--- a/entities/test/unittest_wfobjs.py	Thu Oct 08 11:46:40 2009 +0200
+++ b/entities/test/unittest_wfobjs.py	Thu Oct 08 12:34:31 2009 +0200
@@ -173,15 +173,19 @@
         created    = twf.add_state(_('created'), initial=True)
         identified = twf.add_state(_('identified'))
         released   = twf.add_state(_('released'))
+        closed   = twf.add_state(_('closed'))
         twf.add_wftransition(_('identify'), subwf, (created,),
                              [(xsigned, identified), (xaborted, created)])
         twf.add_wftransition(_('release'), subwf, (identified,),
                              [(xsigned, released), (xaborted, identified)])
+        twf.add_wftransition(_('close'), subwf, (released,),
+                             [(xsigned, closed), (xaborted, released)])
         self.commit()
         group = self.add_entity('CWGroup', name=u'grp1')
         self.commit()
-        for trans in ('identify', 'release'):
+        for trans in ('identify', 'release', 'close'):
             group.fire_transition(trans)
+            self.commit()
 
     def test_subworkflow_base(self):
         """subworkflow
--- a/entities/wfobjs.py	Thu Oct 08 11:46:40 2009 +0200
+++ b/entities/wfobjs.py	Thu Oct 08 12:34:31 2009 +0200
@@ -489,12 +489,13 @@
         if self.main_workflow.eid == self.current_workflow.eid:
             return # doesn't make sense
         subwfentries = []
-        for trinfo in reversed(self.workflow_history):
+        for trinfo in self.workflow_history:
             if (trinfo.transition and
                 trinfo.previous_state.workflow.eid != trinfo.new_state.workflow.eid):
                 # entering or leaving a subworkflow
                 if (subwfentries and
-                    subwfentries[-1].new_state.workflow.eid == trinfo.previous_state.workflow.eid):
+                    subwfentries[-1].new_state.workflow.eid == trinfo.previous_state.workflow.eid and
+                    subwfentries[-1].previous_state.workflow.eid == trinfo.new_state.workflow.eid):
                     # leave
                     del subwfentries[-1]
                 else: