entities/wfobjs.py
changeset 3674 387d51af966d
parent 3629 559cad62c786
parent 3663 c74d8ec4cdb2
child 3675 5d143781a604
--- a/entities/wfobjs.py	Tue Oct 13 18:21:24 2009 +0200
+++ b/entities/wfobjs.py	Thu Oct 15 10:31:54 2009 +0200
@@ -417,17 +417,11 @@
     def cwetype_workflow(self):
         """return the default workflow for entities of this type"""
         # XXX CWEType method
-        wfrset = self._cw.execute('Any WF WHERE X is ET, X eid %(x)s, '
-                                  'WF workflow_of ET', {'x': self.eid}, 'x')
-        if len(wfrset) == 1:
+        wfrset = self._cw.execute('Any WF WHERE ET default_workflow WF, '
+                                  'ET name %(et)s', {'et': self.id})
+        if wfrset:
             return wfrset.get_entity(0, 0)
-        if len(wfrset) > 1:
-            for wf in wfrset.entities():
-                if wf.is_default_workflow_of(self.__regid__):
-                    return wf
-            self.warning("can't find default workflow for %s", self.__regid__)
-        else:
-            self.warning("can't find any workflow for %s", self.__regid__)
+        self.warning("can't find any workflow for %s", self.id)
         return None
 
     def possible_transitions(self, type='normal'):