From b54008f0f2e65bdef7a6b2eed48c8c0ffa9f4ae5 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Mon, 24 Dec 2007 23:26:24 +0000
Subject: [PATCH] Make criterion value type match catalog-returned type.

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

diff --git a/product/ERP5Type/patches/WorkflowTool.py b/product/ERP5Type/patches/WorkflowTool.py
index 3a3f716ace..abbb087d2f 100644
--- a/product/ERP5Type/patches/WorkflowTool.py
+++ b/product/ERP5Type/patches/WorkflowTool.py
@@ -380,12 +380,21 @@ def sumCatalogResultByWorklist(grouped_worklist_dict, catalog_result):
         if not isinstance(criterion_value, ExclusionList):
           criterion_id_dict[criterion_id] = None
     criterion_id_list = criterion_id_dict.keys()
+    class_dict = dict([(name, value.__class__) for name, value in \
+                       zip(catalog_result.names(), catalog_result[0])])
     # Group all worklists concerned by a set of criterion values in
     # criterion_value_to_worklist_key_dict
     # key: criterion value tuple, in the same order as in criterion_id_list
     # value: list of ids of every concerned worklist
     criterion_value_to_worklist_key_dict = {}
     for worklist_id, criterion_dict in grouped_worklist_dict.iteritems():
+      # Transtype values to match catalog-provided type.
+      for criterion_id in criterion_id_list:
+        criterion_value_list = criterion_dict[criterion_id]
+        expected_class = class_dict[criterion_id]
+        if not isinstance(criterion_value_list[0], expected_class):
+          criterion_dict[criterion_id] = [expected_class(x) for x in
+                                          criterion_value_list]
       # Get all the possible combinations of values for all criterions for this
       # worklist. Worklist filtering on portal_type='Foo' and 
       # validation_state in ['draft', 'validated'] is "interested" by both 
-- 
2.30.9