Commit dd3c05fe authored by Yoshinori Okuji's avatar Yoshinori Okuji

Clean up the code.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38158 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 73412c9f
...@@ -716,19 +716,32 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -716,19 +716,32 @@ class OrderBuilder(XMLObject, Amount, Predicate):
""" """
Return a list of movement groups sorted by collect order group and index. Return a list of movement groups sorted by collect order group and index.
""" """
portal = self.getPortalObject()
if portal_type is None:
portal_type = portal.getPortalMovementGroupTypeList()
if collect_order_group is None:
category_index_dict = {} category_index_dict = {}
for i in self.getPortalObject().portal_categories.collect_order_group.contentValues(): for i in portal.portal_categories.collect_order_group.contentValues():
category_index_dict[i.getId()] = i.getIntIndex() category_index_dict[i.getId()] = i.getIntIndex()
def sort_movement_group(a, b): def getMovementGroupKey(movement_group):
return cmp(category_index_dict.get(a.getCollectOrderGroup()), return (category_index_dict.get(movement_group.getCollectOrderGroup()),
category_index_dict.get(b.getCollectOrderGroup())) or \ movement_group.getIntIndex())
cmp(a.getIntIndex(), b.getIntIndex())
if portal_type is None: filter_dict = dict(portal_type=portal_type)
portal_type = self.getPortalMovementGroupTypeList() movement_group_list = self.contentValues(filter=filter_dict)
movement_group_list = [x for x in self.contentValues(filter={'portal_type': portal_type}) \ else:
if collect_order_group is None or collect_order_group == x.getCollectOrderGroup()] def getMovementGroupKey(movement_group):
return sorted(movement_group_list, sort_movement_group) return movement_group.getIntIndex()
filter_dict = dict(portal_type=portal_type)
movement_group_list = []
for movement_group in self.contentValues(filter=filter_dict):
if movement_group.getCollectOrderGroup() == collect_order_group:
movement_group_list.append(movement_group)
return sorted(movement_group_list, key=getMovementGroupKey)
# XXX category name is hardcoded. # XXX category name is hardcoded.
def getDeliveryMovementGroupList(self, **kw): def getDeliveryMovementGroupList(self, **kw):
......
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