Commit 4af43165 authored by Vincent Pelletier's avatar Vincent Pelletier

Apply a change similar with 24944: use buildSQLQuery.

Also, factorise code used to retrieve buildSQLQuery.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24947 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 58ada0e6
...@@ -926,6 +926,7 @@ class SimulationTool(BaseTool): ...@@ -926,6 +926,7 @@ class SimulationTool(BaseTool):
getattr(self, 'Resource_zGetFullInventoryDate', None) getattr(self, 'Resource_zGetFullInventoryDate', None)
EQUAL_DATE_TABLE_ID = 'inventory_stock' EQUAL_DATE_TABLE_ID = 'inventory_stock'
GREATER_THAN_DATE_TABLE_ID = 'stock' GREATER_THAN_DATE_TABLE_ID = 'stock'
buildSQLQuery = self.getPortalObject().portal_catalog.buildSQLQuery
optimisation_success = optimisation__ and ('from_date' not in kw) and \ optimisation_success = optimisation__ and ('from_date' not in kw) and \
Resource_zGetFullInventoryDate is not None and \ Resource_zGetFullInventoryDate is not None and \
(GREATER_THAN_DATE_TABLE_ID == default_stock_table) (GREATER_THAN_DATE_TABLE_ID == default_stock_table)
...@@ -962,7 +963,7 @@ class SimulationTool(BaseTool): ...@@ -962,7 +963,7 @@ class SimulationTool(BaseTool):
if len(date_value_list) == 1: if len(date_value_list) == 1:
date = date_value_list[0] date = date_value_list[0]
# build a query for date to take range into account # build a query for date to take range into account
date_query_result = self.getPortalObject().portal_catalog.buildSQLQuery(**{ date_query_result = buildSQLQuery(**{
'inventory.date': { 'inventory.date': {
'query': date, 'query': date,
'range': column_value_dict.get('date', {}).get('range', []) 'range': column_value_dict.get('date', {}).get('range', [])
...@@ -1053,12 +1054,8 @@ class SimulationTool(BaseTool): ...@@ -1053,12 +1054,8 @@ class SimulationTool(BaseTool):
assert len(equal_date_query_list) == \ assert len(equal_date_query_list) == \
len(greater_than_date_query_list) len(greater_than_date_query_list)
assert len(equal_date_query_list) > 0 assert len(equal_date_query_list) > 0
equal_date_query = ComplexQuery(operator='OR', equal_date_query = buildSQLQuery(query=ComplexQuery(operator='OR', *equal_date_query_list), query_table=None)['where_expression']
*equal_date_query_list).asSQLExpression(**search_key_mapping)\ greater_than_date_query = buildSQLQuery(query=ComplexQuery(operator='OR', *greater_than_date_query_list), query_table=None)['where_expression']
['where_expression']
greater_than_date_query = ComplexQuery(operator='OR',
*greater_than_date_query_list).asSQLExpression(**search_key_mapping)\
['where_expression']
inventory_stock_sql_kw = \ inventory_stock_sql_kw = \
self._generateSQLKeywordDictFromKeywordDict( self._generateSQLKeywordDictFromKeywordDict(
table=EQUAL_DATE_TABLE_ID, sql_kw=sql_kw, new_kw=new_kw) table=EQUAL_DATE_TABLE_ID, sql_kw=sql_kw, new_kw=new_kw)
......
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