[Erp5-report] r19153 - /erp5/trunk/products/ERP5/Tool/SimulationTool.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Feb 8 08:59:12 CET 2008
Author: ivan
Date: Fri Feb 8 08:59:12 2008
New Revision: 19153
URL: http://svn.erp5.org?rev=19153&view=rev
Log:
Simulation Tool uses directly query generation and due to r19152 the APi changed slightly.
Adjust it accordingly.
Modified:
erp5/trunk/products/ERP5/Tool/SimulationTool.py
Modified: erp5/trunk/products/ERP5/Tool/SimulationTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/SimulationTool.py?rev=19153&r1=19152&r2=19153&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/SimulationTool.py (original)
+++ erp5/trunk/products/ERP5/Tool/SimulationTool.py Fri Feb 8 08:59:12 2008
@@ -956,6 +956,7 @@
date = min(date_value_list)
if isinstance(date, DateTime):
date = date.toZone('UTC').ISO()
+
# build a query for date to take range into account
date_query_kw = {"inventory.date" : date,
"operator" : column_value_dict.get('date', {}).get('operator', []),
@@ -995,6 +996,18 @@
# from_date is 2001/01/01.
# It is not a serious problem since MySQL detects incompatible
# conditions and immediately returns (with 0 rows).
+
+ # get search key definitions from portal_catalog
+ ctool = getToolByName(self, 'portal_catalog')
+ portal_catalog_id = ctool.default_sql_catalog_id
+ portal_catalog = getattr(ctool, portal_catalog_id)
+ keyword_search_keys = list(portal_catalog.sql_catalog_keyword_search_keys)
+ datetime_search_keys = list(portal_catalog.sql_catalog_datetime_search_keys)
+ full_text_search_keys = list(portal_catalog.sql_catalog_full_text_search_keys)
+ search_key_mapping = dict(key_alias_dict = None,
+ keyword_search_keys = keyword_search_keys,
+ datetime_search_keys = datetime_search_keys,
+ full_text_search_keys = full_text_search_keys)
equal_date_query_list = []
greater_than_date_query_list = []
EQUAL_DATE_TABLE_ID = 'inventory_stock'
@@ -1017,17 +1030,19 @@
*[Query(**{'%s.%s' % (GREATER_THAN_DATE_TABLE_ID, k): \
v}) \
for k, v in non_date_value_dict.iteritems()]),
+ # 'Use explicitly Universal' otherwise DateTime
+ # search key will convert it to UTC one more time
Query(**{'%s.date' % (GREATER_THAN_DATE_TABLE_ID, ): \
- '>%s' % (date.ISO(), )}),
+ '>%s Universal' % (date.ISO(), )}),
operator='AND'))
assert len(equal_date_query_list) == \
len(greater_than_date_query_list)
assert len(equal_date_query_list) > 0
equal_date_query = ComplexQuery(operator='OR',
- *equal_date_query_list).asSQLExpression()\
+ *equal_date_query_list).asSQLExpression(**search_key_mapping)\
['where_expression']
greater_than_date_query = ComplexQuery(operator='OR',
- *greater_than_date_query_list).asSQLExpression()\
+ *greater_than_date_query_list).asSQLExpression(**search_key_mapping)\
['where_expression']
inventory_stock_sql_kw = \
self._generateSQLKeywordDictFromKeywordDict(
@@ -1422,6 +1437,7 @@
kw['movement_list_mode'] = 1
kw.update(self._getDefaultGroupByParameters(**kw))
sql_kw = self._generateSQLKeywordDict(**kw)
+
return self.Resource_zGetMovementHistoryList(
src__=src__, ignore_variation=ignore_variation,
standardise=standardise,
More information about the Erp5-report
mailing list