Commit 02c75029 authored by Romain Courteaud's avatar Romain Courteaud

Add omit_mirror_date parameter to _generateSQLKeywordDict


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15104 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8e4a0a1a
...@@ -346,6 +346,7 @@ class SimulationTool(BaseTool): ...@@ -346,6 +346,7 @@ class SimulationTool(BaseTool):
def _generateSQLKeywordDict(self, table='stock', def _generateSQLKeywordDict(self, table='stock',
# dates # dates
from_date=None, to_date=None, at_date=None, from_date=None, to_date=None, at_date=None,
omit_mirror_date=1,
# instances # instances
resource=None, node=None, payment=None, resource=None, node=None, payment=None,
section=None, mirror_section=None, item=None, section=None, mirror_section=None, item=None,
...@@ -386,7 +387,10 @@ class SimulationTool(BaseTool): ...@@ -386,7 +387,10 @@ class SimulationTool(BaseTool):
# keywords for related keys # keywords for related keys
**kw): **kw):
""" """
generates keywords and calls buildSQLQuery Generates keywords and calls buildSQLQuery
- omit_mirror_date: normally, date's parameters are only based on date
column. If 0, it also used the mirror_date column.
""" """
new_kw = {} new_kw = {}
new_kw.update(kw) new_kw.update(kw)
...@@ -396,6 +400,9 @@ class SimulationTool(BaseTool): ...@@ -396,6 +400,9 @@ class SimulationTool(BaseTool):
sql_kw['input'] = input sql_kw['input'] = input
sql_kw['output'] = output sql_kw['output'] = output
query_list = []
if omit_mirror_date:
date_dict = {'query':[], 'operator':'and'} date_dict = {'query':[], 'operator':'and'}
if from_date : if from_date :
date_dict['query'].append(from_date) date_dict['query'].append(from_date)
...@@ -414,6 +421,14 @@ class SimulationTool(BaseTool): ...@@ -414,6 +421,14 @@ class SimulationTool(BaseTool):
date_dict['range'] = 'ngt' date_dict['range'] = 'ngt'
if len(date_dict) : if len(date_dict) :
new_kw[table + '.date'] = date_dict new_kw[table + '.date'] = date_dict
else:
date_query_list = []
query_list.append(ComplexQuery(
Query(range='ngt',
**{'%s.date' % table: [to_date]}),
Query(range='nlt',
**{'%s.mirror_date' % table: [from_date]}),
operator='AND'))
# Some columns exists on multiple tables, we have to clear ambiguities # Some columns exists on multiple tables, we have to clear ambiguities
if resource_uid is not None : if resource_uid is not None :
...@@ -521,7 +536,8 @@ class SimulationTool(BaseTool): ...@@ -521,7 +536,8 @@ class SimulationTool(BaseTool):
#if len(variation_category_uid_list) : #if len(variation_category_uid_list) :
# new_kw['variationCategory'] = variation_category_uid_list # new_kw['variationCategory'] = variation_category_uid_list
simulation_query = self._getSimulationStateQuery(simulation_state=simulation_state, simulation_query = self._getSimulationStateQuery(
simulation_state=simulation_state,
omit_transit=omit_transit, omit_transit=omit_transit,
input_simulation_state=input_simulation_state, input_simulation_state=input_simulation_state,
output_simulation_state=output_simulation_state, output_simulation_state=output_simulation_state,
...@@ -555,8 +571,10 @@ class SimulationTool(BaseTool): ...@@ -555,8 +571,10 @@ class SimulationTool(BaseTool):
else: else:
simulation_query = reserved_query simulation_query = reserved_query
if simulation_query is not None: if simulation_query is not None:
new_kw['query'] = simulation_query query_list.append(simulation_query)
if query_list:
new_kw['query'] = ComplexQuery(*query_list)
# It is necessary to use here another SQL query (or at least a subquery) # It is necessary to use here another SQL query (or at least a subquery)
......
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