Commit e37ca409 authored by Vincent Pelletier's avatar Vincent Pelletier

Remove a dependency on ComplexQuery.

Factorise redundant code.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22436 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b3d599ca
...@@ -46,7 +46,7 @@ from Products.ERP5 import DeliverySolver ...@@ -46,7 +46,7 @@ from Products.ERP5 import DeliverySolver
from Products.ERP5 import TargetSolver from Products.ERP5 import TargetSolver
from Products.PythonScripts.Utility import allow_class from Products.PythonScripts.Utility import allow_class
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery, QueryMixin from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery
from Shared.DC.ZRDB.Results import Results from Shared.DC.ZRDB.Results import Results
from Products.ERP5Type.Utils import mergeZRDBResults from Products.ERP5Type.Utils import mergeZRDBResults
...@@ -1642,23 +1642,15 @@ class SimulationTool(BaseTool): ...@@ -1642,23 +1642,15 @@ class SimulationTool(BaseTool):
""" """
new_kw = self._generateSQLKeywordDict(table='item',strict_simulation_state=strict_simulation_state,**kw) new_kw = self._generateSQLKeywordDict(table='item',strict_simulation_state=strict_simulation_state,**kw)
at_date = kw.get('at_date',None) for key in ('at_date', 'to_date'):
if at_date is not None: value = kw.get(key, None)
query_mixin = QueryMixin() if value is not None:
at_date = query_mixin._quoteSQLString(at_date) if isinstance(value, DateTime):
at_date = at_date.strip("'") value = value.toZone('UTC').ISO()
# Do not remove at_date in new_kw, it is required in value = '%s' % (value, )
# Do not remove dates in new_kw, they are required in
# order to do a "select item left join item on date" # order to do a "select item left join item on date"
new_kw['at_date'] = at_date new_kw[key] = value
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 # Extra parameters for the SQL Method
new_kw['join_on_item'] = not history and (new_kw.get('at_date') or \ new_kw['join_on_item'] = not history and (new_kw.get('at_date') or \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment