Commit 7d52e96e authored by Jérome Perrin's avatar Jérome Perrin

accounting: correct access to tool

- get tools from portal, not context, to prevent slow acquisition
- stop using abbreviated names (ctool, stool etc)
parent 62ad8abf
......@@ -6,10 +6,10 @@ params['omit_asset_decrease'] = omit_asset_decrease
# For now, we omit simulation to be compatible with other reports.
params['omit_simulation'] = True
selection_domain = context.portal_selections.getSelectionDomainDictFor(selection_name)
selection_domain = portal.portal_selections.getSelectionDomainDictFor(selection_name)
if callable(selection_domain):
selection_domain = selection_domain()
selection_report = context.portal_selections.getSelectionReportDictFor(selection_name)
selection_report = portal.portal_selections.getSelectionReportDictFor(selection_name)
if selection_domain:
params['selection_domain'] = selection_domain
if selection_report:
......@@ -17,9 +17,9 @@ if selection_report:
if kw.get('closed_summary'):
params['closed_summary'] = kw['closed_summary']
if context.portal_selections.getSelectionInvertModeFor(selection_name):
params['node_uid'] = context.portal_selections.getSelectionInvertModeUidListFor(selection_name)
params['node_uid'] = portal.portal_selections.getSelectionInvertModeUidListFor(selection_name)
else:
selection_params = context.portal_selections.getSelectionParamsFor(selection_name)
selection_params = portal.portal_selections.getSelectionParamsFor(selection_name)
selection_params['ignore_unknown_columns'] = True
params['node_uid'] = [x.uid for x in
portal.portal_catalog(**selection_params)]
......
......@@ -21,15 +21,14 @@ def display(x):
return display_cache[x]
def getGapItemList(only_preferred_gap, gap_root=None):
ctool = portal.portal_categories
if only_preferred_gap:
if gap_root:
return ctool.resolveCategory(gap_root).getCategoryChildItemList(
return portal.portal_categories.resolveCategory(gap_root).getCategoryChildItemList(
base=False, is_self_excluded=True, display_method=display,
local_sort_id=('int_index', 'reference', 'id'))
result = []
for country in ctool.gap.contentValues():
for country in portal.portal_categories.gap.contentValues():
for gap_root in country.contentValues():
result.extend(gap_root.getCategoryChildItemList(
base=False, is_self_excluded=True, display_method=display,
......
......@@ -2,20 +2,19 @@ from Products.ERP5Type.Message import translateString
from zExceptions import Redirect
portal = context.getPortalObject()
stool = portal.portal_selections
countMessage = portal.portal_activities.countMessage
invoice_type_list = portal.getPortalInvoiceTypeList()
stool.updateSelectionCheckedUidList(selection_name, listbox_uid, uids)
selection_uid_list = context.portal_selections.getSelectionCheckedUidsFor(
portal.portal_selections.updateSelectionCheckedUidList(selection_name, listbox_uid, uids)
selection_uid_list = portal.portal_selections.getSelectionCheckedUidsFor(
selection_name)
if selection_uid_list:
object_list = [brain.getObject() for brain in portal.portal_catalog(uid=selection_uid_list)]
else:
object_list = stool.callSelectionFor(selection_name)
object_list = portal.portal_selections.callSelectionFor(selection_name)
# update selection params, because it'll be used in the selection dialog.
stool.setSelectionParamsFor('accounting_create_related_payment_selection',
portal.portal_selections.setSelectionParamsFor('accounting_create_related_payment_selection',
params=dict(node_for_related_payment=node,
payment_mode_for_related_payment=payment_mode,
payment_for_related_payment=payment))
......
from Products.ERP5Type.Message import translateString
from zExceptions import Redirect
portal = context.getPortalObject()
stool = portal.portal_selections
countMessage = portal.portal_activities.countMessage
stool.updateSelectionCheckedUidList(selection_name, listbox_uid, uids)
selection_uid_list = context.portal_selections.getSelectionCheckedUidsFor(
portal.portal_selections.updateSelectionCheckedUidList(selection_name, listbox_uid, uids)
selection_uid_list = portal.portal_selections.getSelectionCheckedUidsFor(
selection_name)
if selection_uid_list:
object_list = [brain.getObject() for brain in portal.portal_catalog(uid=selection_uid_list)]
else:
object_list = stool.callSelectionFor(selection_name)
object_list = portal.portal_selections.callSelectionFor(selection_name)
# XXX prevent to call this on the whole module:
if len(object_list) >= 1000:
......
......@@ -12,7 +12,6 @@ from Products.ERP5Type.Utils import int2letter
lines_per_node = {}
portal = context.getPortalObject()
ctool = portal.portal_catalog
allow_grouping_with_different_quantity = portal.portal_preferences.getPreference(
'preferred_grouping_with_different_quantities', 0)
......
......@@ -45,28 +45,27 @@ if pref.getPreferenceState() == 'disabled':
pref.enable()
# reset selections
stool = context.getPortalObject().portal_selections
for form in context.getPortalObject().portal_skins\
.erp5_accounting.objectValues(spec=('ERP5 Form',)):
listbox = getattr(form, 'listbox', None)
if listbox is not None:
stool.setSelectionFor(listbox.get_value('selection_name'), None)
portal.portal_selections.setSelectionFor(listbox.get_value('selection_name'), None)
# also reset common selections
stool.setSelectionFor('person_selection', None)
stool.setSelectionFor('organisation_selection', None)
stool.setSelectionFor('grouping_reference_fast_input_selection', None)
stool.setSelectionFor('accounting_transaction_module_grouping_reference_fast_input', None)
stool.setSelectionFor('entity_transaction_selection', None)
stool.setSelectionFor('account_module_selection', None)
portal.portal_selections.setSelectionFor('person_selection', None)
portal.portal_selections.setSelectionFor('organisation_selection', None)
portal.portal_selections.setSelectionFor('grouping_reference_fast_input_selection', None)
portal.portal_selections.setSelectionFor('accounting_transaction_module_grouping_reference_fast_input', None)
portal.portal_selections.setSelectionFor('entity_transaction_selection', None)
portal.portal_selections.setSelectionFor('account_module_selection', None)
# set sort order on accounting module
stool.setSelectionParamsFor('accounting_selection', {}) # (this recreates selection)
stool.setSelectionSortOrder('accounting_selection', sort_on=(('operation_date', 'ascending'),))
portal.portal_selections.setSelectionParamsFor('accounting_selection', {}) # (this recreates selection)
portal.portal_selections.setSelectionSortOrder('accounting_selection', sort_on=(('operation_date', 'ascending'),))
# set sort order and columns on account module
stool.setSelectionParamsFor('account_module_selection', {}) # (this recreates selection)
stool.setSelectionSortOrder('account_module_selection', sort_on=(('preferred_gap_id', 'ascending'),))
stool.setSelectionColumns('account_module_selection',
portal.portal_selections.setSelectionParamsFor('account_module_selection', {}) # (this recreates selection)
portal.portal_selections.setSelectionSortOrder('account_module_selection', sort_on=(('preferred_gap_id', 'ascending'),))
portal.portal_selections.setSelectionColumns('account_module_selection',
[('preferred_gap_id', 'GAP Number'),
('translated_title', 'Account Name'),
('translated_validation_state_title', 'State'),
......
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