diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getPersonDetailedContributionList.py b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getPersonDetailedContributionList.py index 5108659d2fd6aa00122c2bd2ae1e2c0f6932744b..2694c0730702c9069722e2f0c49e5335c5933942 100644 --- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getPersonDetailedContributionList.py +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getPersonDetailedContributionList.py @@ -47,15 +47,13 @@ elif to_date is not None: 'range': 'max', 'query': to_date, } -select_expression = {'date' : 'DATE_FORMAT(creation_date, "%s")'%sql_format, 'portal_type' : None} -group_by = ['DATE_FORMAT(creation_date, "%s")' % sql_format, 'portal_type'] # count number of object created by the user for each type of document reference = kw.get('person_reference_list', context.Person_getUserId()) -result_list = context.portal_catalog.countResults(select_expression=select_expression, +result_list = context.portal_catalog.countResults(select_dict={'date': 'DATE_FORMAT(creation_date, "%s")' % sql_format, 'portal_type': None}, portal_type=portal_type_list,limit=None, owner=reference, - group_by_expression=group_by, + group_by=['DATE_FORMAT(creation_date, "%s")' % sql_format, 'portal_type'], **count_kw) # build result dict per portal_type then period diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getPersonDetailedReportSectionList.py b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getPersonDetailedReportSectionList.py index c359b7838b5bce543f7f24def3256bdf7ecf0de2..10d29184f98bcc3fc4eec32cc9912ed3d277c904 100644 --- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getPersonDetailedReportSectionList.py +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getPersonDetailedReportSectionList.py @@ -33,11 +33,11 @@ if context.Person_getUserId() not in (None, ""): selection_columns = [('document_type', "Document Type")] if from_date is None: # get the minimum creation date in catalog - select_expression = "MIN(creation_date)" - group_by = "creation_date" - from_date = DateTime(context.portal_catalog(select_expression=select_expression, - group_by_expression=group_by, - limit=1)[0][2]) + from_date = context.portal_catalog( + select_list=['creation_date'], + sort_on=[['creation_date', 'ASC']], + limit=1, + )[0].creation_date # get period list between given date interval_list_dict = getIntervalListBetweenDates(from_date=from_date, to_date=to_date, keys={'year':aggregation_level=="year", diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_statPersonDetailedContributionList.py b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_statPersonDetailedContributionList.py index 3092df8746f6f77df7012bacfc0de5926a767176..0839066b7a688e332ca1a360c725f30163ceed9a 100644 --- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_statPersonDetailedContributionList.py +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_statPersonDetailedContributionList.py @@ -47,14 +47,12 @@ elif to_date is not None: 'range': 'ngt', 'query': to_date, } -select_expression = {'date' : 'DATE_FORMAT(creation_date, "%s")'%sql_format} -group_by = ['DATE_FORMAT(creation_date, "%s")' % sql_format,] # count number of object created by the user for each type of document -result_list = context.portal_catalog.countResults(select_expression=select_expression, +result_list = context.portal_catalog.countResults(select_dict={'date': 'DATE_FORMAT(creation_date, "%s")' % sql_format}, portal_type=portal_type_list,limit=None, owner=context.Person_getUserId(), - group_by_expression=group_by, + group_by=['DATE_FORMAT(creation_date, "%s")' % sql_format], **count_kw) # build result dict per portal_type then period diff --git a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getAdvancedSearchResultList.py b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getAdvancedSearchResultList.py index 8cbe7edd5ccca6c48c1c410b433f607d955dd299..c5f4008715224e70ab6419adf46f266d519edc8b 100644 --- a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getAdvancedSearchResultList.py +++ b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getAdvancedSearchResultList.py @@ -9,6 +9,7 @@ - if requested, filters result so that only the user's docs are returned - if requested, filters result to return only the newest versions """ +from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery portal = context.getPortalObject() query_kw = {} @@ -49,25 +50,21 @@ for key in ('reference', 'version', 'language',): if value is not None: query_kw[key] = value -where_expression_list = [] +query_list = [] creation_from = parsed_search_string.get('creation_from', None) creation_to = parsed_search_string.get('creation_to', None) modification_from = parsed_search_string.get('modification_from', None) modification_to = parsed_search_string.get('modification_to', None) if creation_from: - where_expression_list.append('catalog.creation_date >= "%s"' \ - %creation_from.strftime(date_format)) + query_list.append(SimpleQuery(creation_date=creation_from.strftime('>=' + date_format))) if creation_to: - where_expression_list.append('catalog.creation_date <= "%s"' \ - %creation_to.strftime(date_format)) + query_list.append(SimpleQuery(creation_date=creation_to.strftime('<=' + date_format))) if modification_from: - where_expression_list.append('catalog.modification_date >= "%s"' \ - %modification_from.strftime(date_format)) + query_list.append(SimpleQuery(modification_date=modification_from.strftime('>=' + date_format))) if modification_to: - where_expression_list.append('catalog.modification_date <= "%s"' \ - %modification_to.strftime(date_format)) -if len(where_expression_list): - query_kw['where_expression'] = ' AND '.join(where_expression_list) + query_list.append(SimpleQuery(modification_date=modification_to.strftime('<=' + date_format))) +if query_list: + query_kw['query'] = ComplexQuery(query_list, logical_operator='and') if parsed_search_string.get('mine', None) is not None: # user wants only his documents diff --git a/bt5/erp5_registry_ohada/SkinTemplateItem/portal_skins/erp5_registry_ohada/PersonModule_getBestCandidateList.py b/bt5/erp5_registry_ohada/SkinTemplateItem/portal_skins/erp5_registry_ohada/PersonModule_getBestCandidateList.py index 66a400fce5de8e0f0a0525fe35fe78a335b2c0f9..a1ce0c13c214982ab504ccf155b5b660d828f7eb 100644 --- a/bt5/erp5_registry_ohada/SkinTemplateItem/portal_skins/erp5_registry_ohada/PersonModule_getBestCandidateList.py +++ b/bt5/erp5_registry_ohada/SkinTemplateItem/portal_skins/erp5_registry_ohada/PersonModule_getBestCandidateList.py @@ -79,18 +79,18 @@ else: Query(birth_date = [DateTime(person_start_date.year(), 1, 1), DateTime(person_start_date.year(), 12, 31),],range = 'minmax'), logical_operator = "AND"), logical_operator = "OR") -select_expression = \ -"""((title ="%s"))AS result_order -""" % (person_title) #select_expression = \ #"""((title ="%s") + (start_date ="%s") + (birthplace_city ="%s"))AS result_order #""" % (person_title, person_start_date, person_birthplace) -candidate_list = context.portal_catalog(portal_type = 'Person', - query = query, - select_expression = select_expression, - sort_on = (('result_order', 'DESC', 'int'),), - select_expression_key = 'result_order') +candidate_list = sorted( + context.portal_catalog( + portal_type='Person', + query=query, + select_list=['title'], + ), + key=lambda x: x.title == person_title +) for candidate in candidate_list: candidate_first_name = candidate.getFirstName() diff --git a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderModule_getOrderReportParameterDict.py b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderModule_getOrderReportParameterDict.py index cda173d833074790761ae51ef6e9ecbcb0fa13a9..b492f6d1b7f94b00d3ae00aeee4f084a2ce61f73 100644 --- a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderModule_getOrderReportParameterDict.py +++ b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderModule_getOrderReportParameterDict.py @@ -37,18 +37,15 @@ if from_date is None: from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery kw = {"delivery.start_date" : None, "key":"DefaultKey"} q = NegatedQuery(Query(**kw)) - select_expression = "MIN(delivery.start_date)" - group_by = "delivery.start_date" from_date = DateTime() result_list = context.portal_catalog( - select_expression=select_expression, - group_by_expression=group_by, + select_dict={'start_date': 'delivery.start_date'}, simulation_state=simulation_state, portal_type=doc_portal_type, query=q, limit=1) if result_list: - from_date = DateTime(result_list[0][2]) + from_date = DateTime(result_list[0].start_date) # get period list between given date