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,24 +400,35 @@ class SimulationTool(BaseTool): ...@@ -396,24 +400,35 @@ class SimulationTool(BaseTool):
sql_kw['input'] = input sql_kw['input'] = input
sql_kw['output'] = output sql_kw['output'] = output
date_dict = {'query':[], 'operator':'and'} query_list = []
if from_date :
date_dict['query'].append(from_date) if omit_mirror_date:
date_dict['range'] = 'min' date_dict = {'query':[], 'operator':'and'}
if to_date : if from_date :
date_dict['query'].append(from_date)
date_dict['range'] = 'min'
if to_date :
date_dict['query'].append(to_date)
date_dict['range'] = 'minmax'
elif at_date :
date_dict['query'].append(at_date)
date_dict['range'] = 'minngt'
elif to_date :
date_dict['query'].append(to_date) date_dict['query'].append(to_date)
date_dict['range'] = 'minmax' date_dict['range'] = 'max'
elif at_date : elif at_date :
date_dict['query'].append(at_date) date_dict['query'].append(at_date)
date_dict['range'] = 'minngt' date_dict['range'] = 'ngt'
elif to_date : if len(date_dict) :
date_dict['query'].append(to_date) new_kw[table + '.date'] = date_dict
date_dict['range'] = 'max' else:
elif at_date : date_query_list = []
date_dict['query'].append(at_date) query_list.append(ComplexQuery(
date_dict['range'] = 'ngt' Query(range='ngt',
if len(date_dict) : **{'%s.date' % table: [to_date]}),
new_kw[table + '.date'] = date_dict 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