From ae29c88f3aceca50ff91ed81638cf09211bab724 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Tue, 4 Mar 2008 17:18:52 +0000
Subject: [PATCH] Fix handling of to_date parameter. It was previously
 comletely broken WRT getTrackingList documentation.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19674 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Tool/SimulationTool.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/product/ERP5/Tool/SimulationTool.py b/product/ERP5/Tool/SimulationTool.py
index 8cb40ddc96..d80943790e 100644
--- a/product/ERP5/Tool/SimulationTool.py
+++ b/product/ERP5/Tool/SimulationTool.py
@@ -1581,8 +1581,18 @@ class SimulationTool(BaseTool):
       # order to do a "select item left join item on date"
       new_kw['at_date'] = at_date
 
+      to_date = kw.get('to_date',None)
+      if to_date is not None:
+        query_mixin = QueryMixin()
+        to_date = query_mixin._quoteSQLString(to_date)
+        to_date = to_date.strip("'")
+      # Do not remove to_date in new_kw, it is required in 
+      # order to do a "select item left join item on date"
+      new_kw['to_date'] = to_date
+
       # Extra parameters for the SQL Method
       new_kw['join_on_item'] = new_kw.get('at_date') or \
+                               new_kw.get('to_date') or \
                                new_kw.get('input') or \
                                new_kw.get('output')
       new_kw['date_condition_in_join'] = not (new_kw.get('input') or new_kw.get('output'))
-- 
2.30.9