Commit c71fc550 authored by Romain Courteaud's avatar Romain Courteaud

Add omit_option_base_category parameter in some methods.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3482 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 22ca046b
...@@ -69,8 +69,10 @@ class Amount(Base, Variated): ...@@ -69,8 +69,10 @@ class Amount(Base, Variated):
# A few more mix-in methods which should be relocated # A few more mix-in methods which should be relocated
# THIS MUST BE UPDATE WITH CATEGORY ACQUISITION # THIS MUST BE UPDATE WITH CATEGORY ACQUISITION
security.declareProtected(Permissions.AccessContentsInformation, 'getVariationCategoryList') security.declareProtected(Permissions.AccessContentsInformation,
def getVariationCategoryList(self, base_category_list = ()): 'getVariationCategoryList')
def getVariationCategoryList(self, base_category_list=(),
omit_option_base_category=0):
""" """
Returns the possible discrete variations Returns the possible discrete variations
(as a list of relative urls to categories) (as a list of relative urls to categories)
...@@ -78,14 +80,15 @@ class Amount(Base, Variated): ...@@ -78,14 +80,15 @@ class Amount(Base, Variated):
result = [] result = []
resource = self.getDefaultResourceValue() resource = self.getDefaultResourceValue()
if resource is not None: if resource is not None:
resource_variation_list = resource.getVariationBaseCategoryList() resource_variation_list = resource.getVariationBaseCategoryList(
omit_option_base_category=omit_option_base_category)
if len(base_category_list) > 0 : if len(base_category_list) > 0 :
variation_list = filter(lambda x: x in base_category_list ,resource_variation_list) variation_list = filter(lambda x: x in base_category_list,
resource_variation_list)
else : else :
variation_list = resource_variation_list variation_list = resource_variation_list
if len(variation_list) > 0: if len(variation_list) > 0:
result = self.getAcquiredCategoryMembershipList(variation_list, base = 1) result = self.getAcquiredCategoryMembershipList(variation_list, base=1)
return result return result
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
...@@ -141,14 +144,17 @@ class Amount(Base, Variated): ...@@ -141,14 +144,17 @@ class Amount(Base, Variated):
self._setVariationCategoryList(value) self._setVariationCategoryList(value)
self.reindexObject() self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent, 'getVariationBaseCategoryList') security.declareProtected(Permissions.ModifyPortalContent,
def getVariationBaseCategoryList(self): 'getVariationBaseCategoryList')
def getVariationBaseCategoryList(self, omit_option_base_category=0):
""" """
Return the list of base_category from all variation related to amount. Return the list of base_category from all variation related to
amount.
It is maybe a nonsense, but useful for correcting user errors. It is maybe a nonsense, but useful for correcting user errors.
""" """
base_category_list = [] base_category_list = []
for category in self.getVariationCategoryList(): for category in self.getVariationCategoryList(
omit_option_base_category=omit_option_base_category):
base_category = category.split('/')[0] base_category = category.split('/')[0]
if base_category not in base_category_list: if base_category not in base_category_list:
base_category_list.append(base_category) base_category_list.append(base_category)
...@@ -202,7 +208,9 @@ class Amount(Base, Variated): ...@@ -202,7 +208,9 @@ class Amount(Base, Variated):
Returns possible variation category values for the Returns possible variation category values for the
order line according to the default resource. order line according to the default resource.
""" """
return [x[1] for x in self.getVariationRangeCategoryItemList()] return [x[1] for x in self.getVariationRangeCategoryItemList(
base_category_list=base_category_list,
base=base)]
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getVariationRangeBaseCategoryList') 'getVariationRangeBaseCategoryList')
......
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