Commit 798ee56e authored by Romain Courteaud's avatar Romain Courteaud

Add getVariationRangeCategoryItemList and getVariationCategoryItemList.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2899 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 292a1168
......@@ -38,6 +38,7 @@ from Products.ERP5Type.Base import Base
from Products.ERP5.Document.Movement import Movement
from Products.ERP5.Variated import Variated
from Products.CMFCategory.Renderer import Renderer
from zLOG import LOG
......@@ -387,3 +388,73 @@ class DeliveryLine(Movement, XMLObject, XMLMatrix, Variated):
parent = self.getParent()
if parent is not None:
parent.updateSimulationDeliveryProperties(movement_list, self)
# XXX Copied
security.declareProtected(Permissions.AccessContentsInformation, \
'getVariationRangeCategoryItemList')
def getVariationRangeCategoryItemList(self):
"""
Returns possible variation category values for the
order line according to the default resource.
Possible category values is provided as a list of
tuples (id, title). This is mostly
useful in ERP5Form instances to generate selection
menus.
"""
resource = self.getResourceValue()
if resource != None:
result = resource.getVariationCategoryItemList(
omit_individual_variation=0)
else:
result = []
return result
security.declareProtected(Permissions.AccessContentsInformation, \
'getVariationRangeCategoryList')
def getVariationRangeCategoryList(self):
"""
Returns possible variation category values for the
order line according to the default resource.
"""
return [x[1] for x in self.getVariationRangeCategoryItemList()]
# XXX Copied from Transformation
security.declareProtected(Permissions.AccessContentsInformation, 'getVariationCategoryItemList')
def getVariationCategoryItemList(self, base_category_list=(), base=1,
display_id='title',
current_category=None):
"""
Returns the list of possible variations
XXX Copied and modified from Variated
Result is left display.
"""
variation_category_item_list = []
if base_category_list == ():
base_category_list = self.getVariationRangeBaseCategoryList()
for base_category in base_category_list:
variation_category_list = self.getVariationCategoryList(
base_category_list=[base_category])
resource_list = [self.portal_categories.resolveCategory(x) for x in\
variation_category_list]
category_list = [x for x in resource_list \
if x.getPortalType() == 'Category']
variation_category_item_list.extend(Renderer(
is_right_display=0,
display_base_category=1,
display_none_category=0, base=base,
current_category=current_category,
display_id='logical_path').\
render(category_list))
object_list = [x for x in resource_list \
if x.getPortalType() != 'Category']
variation_category_item_list.extend(Renderer(
is_right_display=0,
display_base_category=1,
base_category=base_category,
display_none_category=0, base=base,
current_category=current_category,
display_id=display_id).\
render(object_list))
return variation_category_item_list
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