Commit ee950bc7 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

make category calculation through Business Path much faster.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34527 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f24cada6
......@@ -141,6 +141,22 @@ class BusinessPath(Path, Predicate):
#'destination_transport'
)
security.declareProtected(Permissions.AccessContentsInformation,
'getArrowCategoryDict')
def getArrowCategoryDict(self, context=None, **kw):
result = {}
dynamic_category_list = self._getDynamicCategoryList(context)
for base_category in self.getSourceArrowBaseCategoryList() +\
self.getDestinationArrowBaseCategoryList():
category_url_list = Path._getAcquiredCategoryMembershipList(
self, base_category, **kw)
if len(category_url_list) == 0 and context is not None:
category_url_list = self._filterCategoryList(dynamic_category_list,
base_category, **kw)
if len(category_url_list) > 0:
result[base_category] = category_url_list
return result
# ICategoryAccessProvider overridden methods
def _getCategoryMembershipList(self, category, **kw):
"""
......
......@@ -221,26 +221,20 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
if len(business_path_list) == 1:
business_path = business_path_list[0]
property_dict={
'source_value_list': business_path.getSourceValueList(context=context),
'destination_value_list':
business_path.getDestinationValueList(context=context),
'source_section_value_list':
business_path.getSourceSectionValueList(context=context),
'destination_section_value_list':
business_path.getDestinationSectionValueList(context=context),
'source_decision_value_list':
business_path.getSourceDecisionValueList(context=context),
'source_administration_value_list':
business_path.getSourceAdministrationValueList(context=context),
'source_payment_value_list':
business_path.getSourcePaymentValueList(context=context),
'destination_decision_value_list':
business_path.getDestinationDecisionValueList(context=context),
'destination_administration_value_list':
business_path.getDestinationAdministrationValueList(context=context),
'destination_payment_value_list':
business_path.getDestinationPaymentValueList(context=context)
'source':context.getSourceList(),
'destination':context.getDestinationList(),
'source_section':context.getSourceSectionList(),
'destination_section':context.getDestinationSectionList(),
'source_decision':context.getSourceDecisionList(),
'source_administration':context.getSourceAdministrationList(),
'source_payment':context.getSourcePaymentList(),
'destination_decision':context.getDestinationDecisionList(),
'destination_administration':
context.getDestinationAdministrationList(),
'destination_payment':context.getDestinationPaymentList()
}
property_dict.update(
business_path.getArrowCategoryDict(context=context))
common_params = {
'title':self.getTitle(),
......
......@@ -96,13 +96,10 @@ class MovementGeneratorMixin:
return property_dict
# Arrow
for base_category in \
business_path.getSourceArrowBaseCategoryList() +\
business_path.getDestinationArrowBaseCategoryList():
category_url = business_path.getDefaultAcquiredCategoryMembership(
base_category, context=movement)
if category_url not in ['', None]:
property_dict[base_category] = [category_url]
for base_category, category_url_list in \
business_path.getArrowCategoryDict(context=movement).iteritems():
property_dict[base_category] = category_url_list
# Amount
if business_path.getQuantity():
property_dict['quantity'] = business_path.getQuantity()
......
......@@ -558,14 +558,9 @@ class Rule(Predicate, XMLObject):
return property_dict
# Arrow
for base_category in \
business_path.getSourceArrowBaseCategoryList() +\
business_path.getDestinationArrowBaseCategoryList():
# XXX: we need to use _list for categories *always*
category_url = business_path.getDefaultAcquiredCategoryMembership(
base_category, context=movement)
if category_url not in ['', None]:
property_dict['%s_list' % base_category] = [category_url]
for base_category, category_url_list in \
business_path.getArrowCategoryDict(context=movement).iteritems():
property_dict['%s_list' % base_category] = category_url_list
# Amount
property_dict['quantity'] = business_path.getExpectedQuantity(movement)
......
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