Commit 55852792 authored by Vincent Pelletier's avatar Vincent Pelletier

erp5_accounting: Stop using AutoQuery.

parent 79ee8102
from Products.ZSQLCatalog.SQLCatalog import Query from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
from Products.PythonScripts.standard import Object from Products.PythonScripts.standard import Object
from ZTUtils import LazyFilter from ZTUtils import LazyFilter
...@@ -67,7 +67,7 @@ if portal_type and set(portal_type) != set(portal.getPortalAccountingTransaction ...@@ -67,7 +67,7 @@ if portal_type and set(portal_type) != set(portal.getPortalAccountingTransaction
inventory_params['parent_portal_type'] = portal_type inventory_params['parent_portal_type'] = portal_type
if function: if function:
if function == 'None': if function == 'None':
inventory_params['function_uid'] = Query(function_uid=None) inventory_params['function_uid'] = SimpleQuery(function_uid=None)
else: else:
function_value = portal.restrictedTraverse(function, None) function_value = portal.restrictedTraverse(function, None)
if function_value is not None and function_value.getPortalType() != 'Category': if function_value is not None and function_value.getPortalType() != 'Category':
...@@ -76,7 +76,7 @@ if function: ...@@ -76,7 +76,7 @@ if function:
inventory_params['function_category'] = function inventory_params['function_category'] = function
if funding: if funding:
if funding == 'None': if funding == 'None':
inventory_params['funding_uid'] = Query(funding_uid=None) inventory_params['funding_uid'] = SimpleQuery(funding_uid=None)
else: else:
funding_value = portal.restrictedTraverse(funding, None) funding_value = portal.restrictedTraverse(funding, None)
if funding_value is not None and funding_value.getPortalType() != 'Category': if funding_value is not None and funding_value.getPortalType() != 'Category':
...@@ -85,7 +85,7 @@ if funding: ...@@ -85,7 +85,7 @@ if funding:
inventory_params['funding_category'] = funding inventory_params['funding_category'] = funding
if project: if project:
if project == 'None': if project == 'None':
inventory_params['project_uid'] = Query(project_uid=None) inventory_params['project_uid'] = SimpleQuery(project_uid=None)
else: else:
inventory_params['project'] = project inventory_params['project'] = project
if mirror_section_category: if mirror_section_category:
...@@ -93,7 +93,7 @@ if mirror_section_category: ...@@ -93,7 +93,7 @@ if mirror_section_category:
if ledger: if ledger:
if ledger == 'None': if ledger == 'None':
inventory_params['ledger_uid'] = Query(ledger_uid=None) inventory_params['ledger_uid'] = SimpleQuery(ledger_uid=None)
else: else:
if not isinstance(ledger, list): if not isinstance(ledger, list):
# Allows the generation of reports on different ledgers as the same time # Allows the generation of reports on different ledgers as the same time
......
"""Returns the list of columns to use in accounting reports (GL, account statement, journal) """Returns the list of columns to use in accounting reports (GL, account statement, journal)
""" """
from Products.ZSQLCatalog.SQLCatalog import Query from Products.ZSQLCatalog.SQLCatalog import BaseQuery
portal = context.getPortalObject() portal = context.getPortalObject()
request = portal.REQUEST request = portal.REQUEST
...@@ -19,7 +19,7 @@ if funding_item_list: ...@@ -19,7 +19,7 @@ if funding_item_list:
analytic_column_list += (('funding', context.AccountingTransactionLine_getFundingBaseCategoryTitle()),) analytic_column_list += (('funding', context.AccountingTransactionLine_getFundingBaseCategoryTitle()),)
for v, k in funding_item_list: for v, k in funding_item_list:
if k: if k:
if k == 'None' or isinstance(k, Query): if k == 'None' or isinstance(k, BaseQuery):
funding_title_dict[None] = '' funding_title_dict[None] = ''
else: else:
funding_title_dict[portal.portal_categories.restrictedTraverse(k).getUid()] = v funding_title_dict[portal.portal_categories.restrictedTraverse(k).getUid()] = v
...@@ -29,7 +29,7 @@ if function_item_list: ...@@ -29,7 +29,7 @@ if function_item_list:
analytic_column_list += (('function', context.AccountingTransactionLine_getFunctionBaseCategoryTitle()),) analytic_column_list += (('function', context.AccountingTransactionLine_getFunctionBaseCategoryTitle()),)
for v, k in function_item_list: for v, k in function_item_list:
if k: if k:
if k == 'None' or isinstance(k, Query): if k == 'None' or isinstance(k, BaseQuery):
function_title_dict[None] = '' function_title_dict[None] = ''
else: else:
function_title_dict[portal.portal_categories.restrictedTraverse(k).getUid()] = v function_title_dict[portal.portal_categories.restrictedTraverse(k).getUid()] = v
...@@ -39,7 +39,7 @@ if project_item_list: ...@@ -39,7 +39,7 @@ if project_item_list:
analytic_column_list += (('project', 'Project'),) analytic_column_list += (('project', 'Project'),)
for v, k in project_item_list: for v, k in project_item_list:
if k: if k:
if k == 'None' or isinstance(k, Query): if k == 'None' or isinstance(k, BaseQuery):
project_title_dict[None] = '' project_title_dict[None] = ''
else: else:
project_title_dict[portal.portal_categories.restrictedTraverse(k).getUid()] = v project_title_dict[portal.portal_categories.restrictedTraverse(k).getUid()] = v
......
"""Get the report sections for general ledger """Get the report sections for general ledger
""" """
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
from Products.ERP5Form.Report import ReportSection from Products.ERP5Form.Report import ReportSection
portal = context.portal_url.getPortalObject() portal = context.portal_url.getPortalObject()
request = portal.REQUEST request = portal.REQUEST
...@@ -49,14 +49,14 @@ params = dict(precision=precision, ...@@ -49,14 +49,14 @@ params = dict(precision=precision,
project = request.get('project') project = request.get('project')
if project: if project:
if project == 'None': if project == 'None':
params['project_uid'] = Query(project_uid=None) params['project_uid'] = SimpleQuery(project_uid=None)
else: else:
params['project_uid'] = portal.portal_categories.restrictedTraverse(project).getUid() params['project_uid'] = portal.portal_categories.restrictedTraverse(project).getUid()
funding_category = request.get('funding') funding_category = request.get('funding')
if funding_category: if funding_category:
if funding_category == 'None': if funding_category == 'None':
params['funding_uid'] = Query(funding_uid=None) params['funding_uid'] = SimpleQuery(funding_uid=None)
else: else:
funding_value = portal.restrictedTraverse(funding_category, None) funding_value = portal.restrictedTraverse(funding_category, None)
if funding_value is not None and funding_value.getPortalType() != 'Category': if funding_value is not None and funding_value.getPortalType() != 'Category':
...@@ -67,7 +67,7 @@ if funding_category: ...@@ -67,7 +67,7 @@ if funding_category:
function_category = request.get('function') function_category = request.get('function')
if function_category: if function_category:
if function_category == 'None': if function_category == 'None':
params['function_uid'] = Query(function_uid=None) params['function_uid'] = SimpleQuery(function_uid=None)
else: else:
function_value = portal.restrictedTraverse(function_category, None) function_value = portal.restrictedTraverse(function_category, None)
if function_value is not None and function_value.getPortalType() != 'Category': if function_value is not None and function_value.getPortalType() != 'Category':
...@@ -99,8 +99,8 @@ default_selection_params['no_mirror_section_uid_cache'] = 1 ...@@ -99,8 +99,8 @@ default_selection_params['no_mirror_section_uid_cache'] = 1
if request.get('omit_grouping_reference', False): if request.get('omit_grouping_reference', False):
if at_date: if at_date:
params['grouping_query'] = ComplexQuery( params['grouping_query'] = ComplexQuery(
Query(grouping_reference=None), SimpleQuery(grouping_reference=None),
Query(grouping_date=at_date, range="min"), SimpleQuery(grouping_date=at_date, comparison_operator=">="),
logical_operator="OR") logical_operator="OR")
else: else:
params['grouping_reference'] = None params['grouping_reference'] = None
...@@ -318,7 +318,7 @@ for inventory in portal.portal_simulation.getInventoryList( ...@@ -318,7 +318,7 @@ for inventory in portal.portal_simulation.getInventoryList(
selection_params['at_date'] = at_date selection_params['at_date'] = at_date
selection_params['node_uid'] = inventory.node_uid selection_params['node_uid'] = inventory.node_uid
selection_params['payment_uid'] = None selection_params['payment_uid'] = None
selection_params['mirror_section_uid'] = inventory.mirror_section_uid or Query(mirror_section_uid=None) selection_params['mirror_section_uid'] = inventory.mirror_section_uid or SimpleQuery(mirror_section_uid=None)
addReportSection(path=inventory.node_relative_url, addReportSection(path=inventory.node_relative_url,
selection_params=selection_params, selection_params=selection_params,
title=getFullAccountName(key)) title=getFullAccountName(key))
...@@ -347,7 +347,7 @@ for inventory in portal.portal_simulation.getInventoryList( ...@@ -347,7 +347,7 @@ for inventory in portal.portal_simulation.getInventoryList(
selection_params['at_date'] = at_date selection_params['at_date'] = at_date
selection_params['node_uid'] = inventory.node_uid selection_params['node_uid'] = inventory.node_uid
selection_params['payment_uid'] = None selection_params['payment_uid'] = None
selection_params['mirror_section_uid'] = inventory.mirror_section_uid or Query(mirror_section_uid=None) selection_params['mirror_section_uid'] = inventory.mirror_section_uid or SimpleQuery(mirror_section_uid=None)
addReportSection(path=inventory.node_relative_url, addReportSection(path=inventory.node_relative_url,
selection_params=selection_params, selection_params=selection_params,
title=getFullAccountName(key)) title=getFullAccountName(key))
...@@ -372,7 +372,7 @@ for inventory in portal.portal_simulation.getInventoryList( ...@@ -372,7 +372,7 @@ for inventory in portal.portal_simulation.getInventoryList(
selection_params['from_date'] = from_date selection_params['from_date'] = from_date
selection_params['at_date'] = at_date selection_params['at_date'] = at_date
selection_params['node_uid'] = inventory.node_uid selection_params['node_uid'] = inventory.node_uid
selection_params['payment_uid'] = inventory.payment_uid or Query(payment_uid=None) selection_params['payment_uid'] = inventory.payment_uid or SimpleQuery(payment_uid=None)
selection_params.setdefault('mirror_section_uid', None) selection_params.setdefault('mirror_section_uid', None)
addReportSection(path=inventory.node_relative_url, addReportSection(path=inventory.node_relative_url,
selection_params=selection_params, selection_params=selection_params,
...@@ -400,7 +400,7 @@ for inventory in portal.portal_simulation.getInventoryList( ...@@ -400,7 +400,7 @@ for inventory in portal.portal_simulation.getInventoryList(
selection_params['from_date'] = from_date selection_params['from_date'] = from_date
selection_params['at_date'] = at_date selection_params['at_date'] = at_date
selection_params['node_uid'] = inventory.node_uid selection_params['node_uid'] = inventory.node_uid
selection_params['payment_uid'] = inventory.payment_uid or Query(payment_uid=None) selection_params['payment_uid'] = inventory.payment_uid or SimpleQuery(payment_uid=None)
selection_params.setdefault('mirror_section_uid', None) selection_params.setdefault('mirror_section_uid', None)
addReportSection(path=inventory.node_relative_url, addReportSection(path=inventory.node_relative_url,
selection_params=selection_params, selection_params=selection_params,
......
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
from Products.PythonScripts.standard import Object from Products.PythonScripts.standard import Object
portal = context.getPortalObject() portal = context.getPortalObject()
params = portal.ERP5Site_getAccountingSelectionParameterDict(selection_name) params = portal.ERP5Site_getAccountingSelectionParameterDict(selection_name)
...@@ -15,8 +15,8 @@ at_date = (from_date - 1).latestTime() ...@@ -15,8 +15,8 @@ at_date = (from_date - 1).latestTime()
inventory_query = { inventory_query = {
'at_date': at_date, # this is not to_date 'at_date': at_date, # this is not to_date
'grouping_query': ComplexQuery( 'grouping_query': ComplexQuery(
Query(grouping_reference=None), SimpleQuery(grouping_reference=None),
Query(grouping_date=at_date, range="min"), SimpleQuery(grouping_date=at_date, comparison_operator=">="),
logical_operator="OR"), logical_operator="OR"),
'simulation_state': params['simulation_state'], 'simulation_state': params['simulation_state'],
'node_uid': kw['node_uid'], 'node_uid': kw['node_uid'],
......
"""Creates a balance transaction to open the next period. """Creates a balance transaction to open the next period.
""" """
from Products.ZSQLCatalog.SQLCatalog import Query from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
portal = context.getPortalObject() portal = context.getPortalObject()
Base_translateString = portal.Base_translateString Base_translateString = portal.Base_translateString
...@@ -102,7 +102,7 @@ with context.defaultActivateParameterDict({'tag': activity_tag}, placeless=True) ...@@ -102,7 +102,7 @@ with context.defaultActivateParameterDict({'tag': activity_tag}, placeless=True)
ledger_uid = ledger.getUid() ledger_uid = ledger.getUid()
ledger_url = ledger.getCategoryRelativeUrl() ledger_url = ledger.getCategoryRelativeUrl()
else: else:
ledger_uid = Query(ledger_uid=None) ledger_uid = SimpleQuery(ledger_uid=None)
ledger_url = '' ledger_url = ''
for section in section_list: for section in section_list:
......
from Products.ZSQLCatalog.SQLCatalog import Query from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
from Products.CMFActivity.ActiveResult import ActiveResult from Products.CMFActivity.ActiveResult import ActiveResult
portal = context.getPortalObject() portal = context.getPortalObject()
...@@ -12,7 +12,7 @@ precision_by_section_uid = {} ...@@ -12,7 +12,7 @@ precision_by_section_uid = {}
def check(node_uid, section_uid, mirror_section_uid): def check(node_uid, section_uid, mirror_section_uid):
precision = precision_by_section_uid[section_uid] precision = precision_by_section_uid[section_uid]
if mirror_section_uid is None: if mirror_section_uid is None:
mirror_section_uid = Query(mirror_section_uid=None) mirror_section_uid = SimpleQuery(mirror_section_uid=None)
line_list = portal.portal_simulation.getMovementHistoryList( line_list = portal.portal_simulation.getMovementHistoryList(
portal_type=portal.getPortalAccountingMovementTypeList(), portal_type=portal.getPortalAccountingMovementTypeList(),
grouping_reference=context.getGroupingReference(), grouping_reference=context.getGroupingReference(),
......
from Products.ZSQLCatalog.SQLCatalog import Query from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
from Products.PythonScripts.standard import Object from Products.PythonScripts.standard import Object
request = container.REQUEST request = container.REQUEST
portal = context.getPortalObject() portal = context.getPortalObject()
...@@ -15,7 +15,7 @@ if group_by: ...@@ -15,7 +15,7 @@ if group_by:
if project_uid: if project_uid:
if project_uid == 'None': if project_uid == 'None':
extra_kw['project_uid'] = Query(project_uid=None) extra_kw['project_uid'] = SimpleQuery(project_uid=None)
else: else:
extra_kw['project_uid'] = project_uid extra_kw['project_uid'] = project_uid
......
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery, ComplexQuery from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery, ComplexQuery
request = container.REQUEST request = container.REQUEST
portal = context.getPortalObject() portal = context.getPortalObject()
...@@ -62,11 +62,11 @@ if grouping == 'grouping': ...@@ -62,11 +62,11 @@ if grouping == 'grouping':
search_kw['grouping_reference'] = None search_kw['grouping_reference'] = None
else: else:
assert grouping == 'ungrouping', grouping assert grouping == 'ungrouping', grouping
search_kw['grouping_reference'] = NegatedQuery(Query(grouping_reference=None)) search_kw['grouping_reference'] = NegatedQuery(SimpleQuery(grouping_reference=None))
if title: if title:
search_kw['title_query'] = ComplexQuery(Query(title=title), search_kw['title_query'] = ComplexQuery(SimpleQuery(title=title),
Query(parent_title=title), SimpleQuery(parent_title=title),
logical_operator='OR') logical_operator='OR')
if delivery_reference: if delivery_reference:
search_kw['parent_reference'] = delivery_reference search_kw['parent_reference'] = delivery_reference
......
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
from Products.ERP5Type.Log import log from Products.ERP5Type.Log import log
portal = context.getPortalObject() portal = context.getPortalObject()
...@@ -38,20 +38,20 @@ for category_uid in category_uid_list: ...@@ -38,20 +38,20 @@ for category_uid in category_uid_list:
# that specific project, or select a special value "None" which means # that specific project, or select a special value "None" which means
# transactions that are not related to a project. For that we need a # transactions that are not related to a project. For that we need a
# query that will be translated as stock.project_uid IS NULL. # query that will be translated as stock.project_uid IS NULL.
params[category_uid] = Query(**{category_uid: None}) params[category_uid] = SimpleQuery(**{category_uid: None})
else: else:
params[category_uid] = category_uid_value params[category_uid] = category_uid_value
funding_category = kw.get('funding_category') funding_category = kw.get('funding_category')
if funding_category: if funding_category:
if funding_category == 'None': if funding_category == 'None':
params['funding_uid'] = Query(funding_uid=None) params['funding_uid'] = SimpleQuery(funding_uid=None)
else: else:
params['funding_category'] = funding_category params['funding_category'] = funding_category
function_category = kw.get('function_category') function_category = kw.get('function_category')
if function_category: if function_category:
if function_category == 'None': if function_category == 'None':
params['function_uid'] = Query(function_uid=None) params['function_uid'] = SimpleQuery(function_uid=None)
else: else:
params['function_category'] = function_category params['function_category'] = function_category
...@@ -90,8 +90,8 @@ if is_pl_account and not from_date: ...@@ -90,8 +90,8 @@ if is_pl_account and not from_date:
if portal.portal_selections.getSelectionParamsFor(selection_name).get('omit_grouping_reference'): if portal.portal_selections.getSelectionParamsFor(selection_name).get('omit_grouping_reference'):
if params.get('at_date'): if params.get('at_date'):
params['grouping_query'] = ComplexQuery( params['grouping_query'] = ComplexQuery(
Query(grouping_reference=None), SimpleQuery(grouping_reference=None),
Query(grouping_date=params['at_date'], range="min"), SimpleQuery(grouping_date=params['at_date'], comparison_operator=">="),
logical_operator="OR") logical_operator="OR")
else: else:
params['grouping_reference'] = None params['grouping_reference'] = None
......
from Products.ZSQLCatalog.SQLCatalog import Query from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
portal = context.getPortalObject() portal = context.getPortalObject()
params = portal.ERP5Site_getAccountingSelectionParameterDict(selection_name=selection_name) params = portal.ERP5Site_getAccountingSelectionParameterDict(selection_name=selection_name)
...@@ -28,20 +28,20 @@ for category_uid in category_uid_list: ...@@ -28,20 +28,20 @@ for category_uid in category_uid_list:
# that specific project, or select a special value "None" which means # that specific project, or select a special value "None" which means
# transactions that are not related to a project. For that we need a # transactions that are not related to a project. For that we need a
# query that will be translated as stock.project_uid IS NULL. # query that will be translated as stock.project_uid IS NULL.
params[category_uid] = Query(**{category_uid: None}) params[category_uid] = SimpleQuery(**{category_uid: None})
else: else:
params[category_uid] = category_uid_value params[category_uid] = category_uid_value
funding_category = kw.get('funding_category') funding_category = kw.get('funding_category')
if funding_category: if funding_category:
if funding_category == 'None': if funding_category == 'None':
params['funding_uid'] = Query(funding_uid=None) params['funding_uid'] = SimpleQuery(funding_uid=None)
else: else:
params['funding_category'] = funding_category params['funding_category'] = funding_category
function_category = kw.get('function_category') function_category = kw.get('function_category')
if function_category: if function_category:
if function_category == 'None': if function_category == 'None':
params['function_uid'] = Query(function_uid=None) params['function_uid'] = SimpleQuery(function_uid=None)
else: else:
params['function_category'] = function_category params['function_category'] = function_category
......
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