From d2aad094fd04bd68f85281bc20e489a4bf308714 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Thu, 8 Nov 2007 15:25:00 +0000
Subject: [PATCH] Fix an error in query generation when there is just one
 criterion in worklist (including security criterion if any).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17477 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/patches/WorkflowTool.py | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/product/ERP5Type/patches/WorkflowTool.py b/product/ERP5Type/patches/WorkflowTool.py
index 72bd3b479a..299829f232 100644
--- a/product/ERP5Type/patches/WorkflowTool.py
+++ b/product/ERP5Type/patches/WorkflowTool.py
@@ -251,21 +251,20 @@ def generateNestedQuery(priority_list, criterion_dict,
   else:
     possible_value_list = tuple()
     impossible_value_list = tuple()
-    if possible_worklist_id_dict is not None:
-      for criterion_value, criterion_worklist_id_dict \
-          in my_criterion_dict.iteritems():
+    possible = True
+    for criterion_value, criterion_worklist_id_dict \
+        in my_criterion_dict.iteritems():
+      if possible_worklist_id_dict is not None:
         possible = False
         for worklist_id in criterion_worklist_id_dict.iterkeys():
           if worklist_id in possible_worklist_id_dict:
             possible = True
             break
-        if possible:
-          if isinstance(criterion_value, ExclusionTuple):
-            impossible_value_list += criterion_value
-          else:
-            possible_value_list += criterion_value
-    else:
-      possible_value_list = my_criterion_dict.keys()
+      if possible:
+        if isinstance(criterion_value, ExclusionTuple):
+          impossible_value_list += criterion_value
+        else:
+          possible_value_list += criterion_value
     value_query_list = []
     if len(possible_value_list):
       query = Query(operator='IN', **{my_criterion_id: possible_value_list})
-- 
2.30.9