Commit acb0aefa authored by Jérome Perrin's avatar Jérome Perrin

accounting: reflect changes of "Account Number Method" immediately

Make it part of the caching method id so that changing the preference
immediately show new accounts.

This also moves the "user_name" argument that was an artificial parameter
not used only here to make the cache vary to the cache id, for
consistency and clarity.
parent cf66c478
...@@ -54,7 +54,7 @@ def sort(x,y): ...@@ -54,7 +54,7 @@ def sort(x,y):
return cmp(display(x), display(y)) return cmp(display(x), display(y))
def getItemList(category=None, portal_path=None, mirror=0, omit_filter=0, def getItemList(category=None, portal_path=None, mirror=0, omit_filter=0,
user_name=None, simulation_state=None): simulation_state=None):
"""Returns a list of Account path items. """ """Returns a list of Account path items. """
if category is not None: if category is not None:
cat = portal.portal_categories.resolveCategory(category) cat = portal.portal_categories.resolveCategory(category)
...@@ -78,8 +78,12 @@ def getItemList(category=None, portal_path=None, mirror=0, omit_filter=0, ...@@ -78,8 +78,12 @@ def getItemList(category=None, portal_path=None, mirror=0, omit_filter=0,
# wrap the previous method in a cache, including the cache cookie that # wrap the previous method in a cache, including the cache cookie that
# we reset everytime and account is validated or invalidated. # we reset everytime and account is validated or invalidated.
cache_cookie = portal.account_module.getCacheCookie('account_list') cache_cookie = portal.account_module.getCacheCookie('account_list')
getItemList = CachingMethod(getItemList, getItemList = CachingMethod(
id='AccountingTransactionLine_getNodeItemList-%s' % cache_cookie, getItemList,
id='AccountingTransactionLine_getNodeItemList-%s-%s-%s' % (
cache_cookie,
getSecurityManager().getUser().getIdOrUserName(),
portal.portal_preferences.getPreferredAccountNumberMethod()),
cache_factory='erp5_content_long') cache_factory='erp5_content_long')
# the cache vary with the simulation state of the current transaction, # the cache vary with the simulation state of the current transaction,
...@@ -91,7 +95,6 @@ item_list = getItemList( category=category, ...@@ -91,7 +95,6 @@ item_list = getItemList( category=category,
portal_path=context.getPortalObject().getPhysicalPath(), portal_path=context.getPortalObject().getPhysicalPath(),
mirror=mirror, mirror=mirror,
omit_filter=omit_filter, # XXX possible optim: only one cache if omit_filter omit_filter=omit_filter, # XXX possible optim: only one cache if omit_filter
user_name=getSecurityManager().getUser().getIdOrUserName(),
simulation_state=simulation_state) simulation_state=simulation_state)
# make sure that the current value is included in this list, this is # make sure that the current value is included in this list, this is
......
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