Commit 78e1bfe9 authored by Romain Courteaud's avatar Romain Courteaud

Clean variation method and make the code more generic.

Fix testTransformation (variation was not well defined).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5246 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 13b3ccf0
...@@ -132,7 +132,8 @@ class Amount(Base, Variated): ...@@ -132,7 +132,8 @@ class Amount(Base, Variated):
render(object_list)) render(object_list))
return variation_category_item_list return variation_category_item_list
security.declareProtected(Permissions.ModifyPortalContent, '_setVariationCategoryList') security.declareProtected(Permissions.ModifyPortalContent,
'_setVariationCategoryList')
def _setVariationCategoryList(self, value): def _setVariationCategoryList(self, value):
result = [] result = []
resource = self.getDefaultResourceValue() resource = self.getDefaultResourceValue()
...@@ -141,7 +142,8 @@ class Amount(Base, Variated): ...@@ -141,7 +142,8 @@ class Amount(Base, Variated):
if len(variation_list) > 0: if len(variation_list) > 0:
self._setCategoryMembership(variation_list, value, base = 1) self._setCategoryMembership(variation_list, value, base = 1)
security.declareProtected(Permissions.ModifyPortalContent, 'setVariationCategoryList') security.declareProtected(Permissions.ModifyPortalContent,
'setVariationCategoryList')
def setVariationCategoryList(self, value): def setVariationCategoryList(self, value):
self._setVariationCategoryList(value) self._setVariationCategoryList(value)
self.reindexObject() self.reindexObject()
...@@ -162,7 +164,18 @@ class Amount(Base, Variated): ...@@ -162,7 +164,18 @@ class Amount(Base, Variated):
base_category_list.append(base_category) base_category_list.append(base_category)
return base_category_list return base_category_list
security.declareProtected(Permissions.AccessContentsInformation, 'getVariationValue') security.declareProtected(Permissions.AccessContentsInformation,
'getVariationBaseCategoryItemList')
def getVariationBaseCategoryItemList(self,display_id='title_or_id',**kw):
"""
Returns a list of base_category tuples.
"""
return self.portal_categories.getItemList(
self.getVariationBaseCategoryList(),
display_id=display_id,**kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getVariationValue')
def getVariationValue(self): def getVariationValue(self):
""" """
New Method for dicrete and countinuous variations New Method for dicrete and countinuous variations
...@@ -215,7 +228,7 @@ class Amount(Base, Variated): ...@@ -215,7 +228,7 @@ class Amount(Base, Variated):
base=base, **kw)] base=base, **kw)]
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getVariationRangeBaseCategoryList') 'getVariationRangeBaseCategoryList')
def getVariationRangeBaseCategoryList(self, omit_option_base_category=0): def getVariationRangeBaseCategoryList(self, omit_option_base_category=0):
""" """
Returns possible variations base categories for this amount ie. Returns possible variations base categories for this amount ie.
...@@ -232,7 +245,7 @@ class Amount(Base, Variated): ...@@ -232,7 +245,7 @@ class Amount(Base, Variated):
result = resource.getVariationBaseCategoryList( result = resource.getVariationBaseCategoryList(
omit_option_base_category=omit_option_base_category) omit_option_base_category=omit_option_base_category)
else: else:
result = self.portal_categories.getBaseCategoryList() result = Variated.getVariationRangeBaseCategoryList(self)
return result return result
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
......
...@@ -60,20 +60,23 @@ class Consumption(XMLObject, XMLMatrix, Variated): ...@@ -60,20 +60,23 @@ class Consumption(XMLObject, XMLMatrix, Variated):
# , PropertySheet.Consumption # , PropertySheet.Consumption
) )
security.declareProtected(Permissions.ModifyPortalContent, '_setVariationCategoryList') security.declareProtected(Permissions.ModifyPortalContent,
'_setVariationCategoryList')
def _setVariationCategoryList(self,value): def _setVariationCategoryList(self,value):
""" """
Set consumption variation category list. Set consumption variation category list.
Set matrix cell range. Set matrix cell range.
""" """
self._setCategoryMembership(self.getVariationRangeBaseCategoryList(),value,base=1) self._setCategoryMembership(self.getVariationRangeBaseCategoryList(),
value, base=1)
# XXX Must use in futur this method, but it failed today # XXX Must use in futur this method, but it failed today
#Variated._setVariationCategoryList(self, value) #Variated._setVariationCategoryList(self, value)
# XXX FIXME: Use a interaction workflow instead # XXX FIXME: Use a interaction workflow instead
# Kept for compatibility. # Kept for compatibility.
self.updateCellRange(base_id='quantity') self.updateCellRange(base_id='quantity')
security.declareProtected(Permissions.ModifyPortalContent, 'setVariationCategoryList') security.declareProtected(Permissions.ModifyPortalContent,
'setVariationCategoryList')
def setVariationCategoryList(self,value): def setVariationCategoryList(self,value):
""" """
Set consumption variation category list. Set consumption variation category list.
...@@ -82,14 +85,8 @@ class Consumption(XMLObject, XMLMatrix, Variated): ...@@ -82,14 +85,8 @@ class Consumption(XMLObject, XMLMatrix, Variated):
self._setVariationCategoryList(value) self._setVariationCategoryList(value)
self.reindexObject() self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent, 'getVariationRangeBaseCategoryList') security.declareProtected(Permissions.ModifyPortalContent,
def getVariationRangeBaseCategoryList(self): 'getVariationRangeBaseCategoryItemList')
"""
Return range of base variation
"""
return self.getPortalVariationBaseCategoryList()
security.declareProtected(Permissions.ModifyPortalContent, 'getVariationRangeBaseCategoryItemList')
def getVariationRangeBaseCategoryItemList(self): def getVariationRangeBaseCategoryItemList(self):
""" """
Return range of base variation item Return range of base variation item
...@@ -98,33 +95,18 @@ class Consumption(XMLObject, XMLMatrix, Variated): ...@@ -98,33 +95,18 @@ class Consumption(XMLObject, XMLMatrix, Variated):
# XXX get TitleOrId # XXX get TitleOrId
return map( lambda x: (x,x) , self.getVariationRangeBaseCategoryList() ) return map( lambda x: (x,x) , self.getVariationRangeBaseCategoryList() )
security.declareProtected(Permissions.ModifyPortalContent, 'getVariationRangeCategoryList') security.declareProtected(Permissions.ModifyPortalContent,
def getVariationRangeCategoryList(self): 'getQuantityRatio')
""" def getQuantityRatio(self, variation_category_line,
Return range of variation variation_category_column):
"""
result = self.portal_categories.getCategoryChildList(self.getVariationBaseCategoryList(), base=0)
return result
security.declareProtected(Permissions.ModifyPortalContent, 'getVariationRangeCategoryItemList')
def getVariationRangeCategoryItemList(self):
"""
Return range of variation item
"""
# We need a left display for ListField, and self.portal_categories.getCategoryChildTitleItemList return a right display
# So, invert all tuples
result = map( lambda x: (x[1],x[0]), self.portal_categories.getCategoryChildTitleItemList(self.getVariationBaseCategoryList(), base=1) )
return result
security.declareProtected(Permissions.ModifyPortalContent, 'getQuantityRatio')
def getQuantityRatio(self, variation_category_line, variation_category_column):
""" """
Return quantity ratio for a virtual cell. Return quantity ratio for a virtual cell.
Return None if not result can be return. Return None if not result can be return.
""" """
cell_quantity_ratio_list = [] cell_quantity_ratio_list = []
for variation_category in (variation_category_line, variation_category_column): for variation_category in (variation_category_line,
variation_category_column):
cell = self.getCell(variation_category, base_id='quantity') cell = self.getCell(variation_category, base_id='quantity')
if cell is None: if cell is None:
return None return None
......
...@@ -77,7 +77,8 @@ class DeliveryLine(Movement, XMLObject, XMLMatrix, Variated): ...@@ -77,7 +77,8 @@ class DeliveryLine(Movement, XMLObject, XMLMatrix, Variated):
updateRelatedContent = XMLMatrix.updateRelatedContent updateRelatedContent = XMLMatrix.updateRelatedContent
# Explicit acquisition of aq_dynamic generated method # Explicit acquisition of aq_dynamic generated method
security.declareProtected(Permissions.AccessContentsInformation, 'getSimulationState') security.declareProtected(Permissions.AccessContentsInformation,
'getSimulationState')
def getSimulationState(self): def getSimulationState(self):
""" """
Explicitly acquire simulation_state from parent Explicitly acquire simulation_state from parent
......
...@@ -187,12 +187,12 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -187,12 +187,12 @@ class Resource(XMLMatrix, CoreResource, Variated):
# XXX now, call Renderer a lot of time. # XXX now, call Renderer a lot of time.
# Better implementation needed # Better implementation needed
result.extend(Renderer( result.extend(Renderer(
base_category=base_category, base_category=base_category,
display_base_category=display_base_category, display_base_category=display_base_category,
display_none_category=0, base=base, display_none_category=0, base=base,
current_category=current_category, current_category=current_category,
display_id=display_id, **kw).\ display_id=display_id, **kw).\
render([object])) render([object]))
return result return result
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
...@@ -228,8 +228,8 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -228,8 +228,8 @@ class Resource(XMLMatrix, CoreResource, Variated):
| morphology/2 | (morphology/2, ) | morphology/2 | (morphology/2, )
""" """
vcil = self.getVariationCategoryItemList( vcil = self.getVariationCategoryItemList(
base_category_list=base_category_list, base_category_list=base_category_list,
omit_individual_variation=omit_individual_variation,**kw) omit_individual_variation=omit_individual_variation,**kw)
return map(lambda x: x[1], vcil) return map(lambda x: x[1], vcil)
# Unit conversion # Unit conversion
......
...@@ -95,24 +95,6 @@ class Transformation(XMLObject, Predicate, Variated): ...@@ -95,24 +95,6 @@ class Transformation(XMLObject, Predicate, Variated):
for transformation_line in transformation_line_list: for transformation_line in transformation_line_list:
transformation_line.updateVariationCategoryList() transformation_line.updateVariationCategoryList()
security.declareProtected(Permissions.AccessContentsInformation,
'getVariationRangeBaseCategoryList')
def getVariationRangeBaseCategoryList(self):
"""
Returns possible variation base_category ids of the
default resource which can be used a variation axis
in the transformation.
"""
resource = self.getResourceValue()
if resource is not None:
result = resource.getVariationBaseCategoryList()
else:
# XXX result = self.getBaseCategoryIds()
# Why calling this method ?
# Get a global variable which define a list of variation base category
result = self.getPortalVariationBaseCategoryList()
return result
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getVariationRangeBaseCategoryItemList') 'getVariationRangeBaseCategoryItemList')
def getVariationRangeBaseCategoryItemList(self,display_id='title_or_id',**kw): def getVariationRangeBaseCategoryItemList(self,display_id='title_or_id',**kw):
...@@ -122,39 +104,14 @@ class Transformation(XMLObject, Predicate, Variated): ...@@ -122,39 +104,14 @@ class Transformation(XMLObject, Predicate, Variated):
useful in ERP5Form instances to generate selection useful in ERP5Form instances to generate selection
menus. menus.
""" """
return self.portal_categories.getItemList( self.getVariationRangeBaseCategoryList(), return self.portal_categories.getItemList(
display_id=display_id,**kw ) self.getVariationRangeBaseCategoryList(),
display_id=display_id, **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getVariationRangeCategoryList')
def getVariationRangeCategoryList(self, base_category_list=()):
"""
Returns possible variation category values for the
transformation according to the default resource.
Possible category values is provided as a list of
id.
User may want to define generic transformation without
any resource define.
Result is left display.
"""
if base_category_list is ():
base_category_list = self.getVariationBaseCategoryList()
resource = self.getResourceValue()
if resource != None:
result = resource.getVariationCategoryList(
base_category_list=base_category_list,
omit_individual_variation=0)
else:
# No resource is define on transformation. We want to display content of base categories
result = self.portal_categories.getCategoryChildList(base_category_list, base=1)
return result
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getVariationRangeCategoryItemList') 'getVariationRangeCategoryItemList')
def getVariationRangeCategoryItemList(self, base_category_list=(), def getVariationRangeCategoryItemList(self, base_category_list=(),
display_base_category=1,**kw): display_base_category=1, **kw):
""" """
Returns possible variation category values for the Returns possible variation category values for the
transformation according to the default resource. transformation according to the default resource.
...@@ -171,24 +128,16 @@ class Transformation(XMLObject, Predicate, Variated): ...@@ -171,24 +128,16 @@ class Transformation(XMLObject, Predicate, Variated):
resource = self.getResourceValue() resource = self.getResourceValue()
if resource != None: if resource != None:
result = resource.getVariationCategoryItemList( result = resource.getVariationCategoryItemList(
base_category_list=base_category_list, base_category_list=base_category_list,
omit_individual_variation=0, omit_individual_variation=0,
display_base_category=display_base_category,**kw) display_base_category=display_base_category,**kw)
else: else:
# No resource is define on transformation. We want to display content of base categories # No resource is define on transformation.
result = self.portal_categories.getCategoryChildTitleItemList(base_category_list, base=1, display_none_category=0) # We want to display content of base categories
result = self.portal_categories.getCategoryChildTitleItemList(
base_category_list, base=1, display_none_category=0)
return result return result
security.declareProtected(Permissions.AccessContentsInformation,
'getVariationBaseCategoryItemList')
def getVariationBaseCategoryItemList(self,display_id='title_or_id',**kw):
"""
Returns a list of base_category tuples for this tranformation
"""
return self.portal_categories.getItemList(self.getVariationBaseCategoryList(),
display_id=display_id,**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'_setVariationBaseCategoryList') '_setVariationBaseCategoryList')
def _setVariationBaseCategoryList(self, value): def _setVariationBaseCategoryList(self, value):
......
...@@ -162,51 +162,6 @@ class TransformedResource(Predicate, XMLObject, XMLMatrix, Amount): ...@@ -162,51 +162,6 @@ class TransformedResource(Predicate, XMLObject, XMLMatrix, Amount):
self._setVVariationBaseCategoryList(value) self._setVVariationBaseCategoryList(value)
self.reindexObject() self.reindexObject()
security.declareProtected(Permissions.AccessContentsInformation,
'getVariationRangeCategoryItemList')
def getVariationRangeCategoryItemList(self, base_category_list = (),
omit_individual_variation=1, base=1,
current_category=None,
display_base_category=1,
display_id='title', **kw):
"""
Returns possible variation category values for the
transformation 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.
Display is left...
"""
resource = self.getResourceValue()
result = []
if resource != None:
if base_category_list is ():
base_category_list = resource.getVariationBaseCategoryList()
result = resource.getVariationCategoryItemList(
base_category_list=base_category_list,
omit_individual_variation=0,
base=base,
current_category=current_category,
display_base_category=display_base_category,
display_id=display_id,
**kw)
return result
security.declareProtected(Permissions.AccessContentsInformation,
'getVariationRangeCategoryItemList')
def getVariationRangeCategoryList(self, base_category_list=()):
"""
Returns possible variation category values for the
transformation according to the default resource.
"""
return map(lambda x: x[1],
self.getVariationRangeCategoryItemList(
base_category_list=base_category_list))
return result
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getAggregatedAmountList') 'getAggregatedAmountList')
def getAggregatedAmountList(self, context=None, REQUEST=None, **kw): def getAggregatedAmountList(self, context=None, REQUEST=None, **kw):
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002, 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com> # Jean-Paul Smets-Solanes <jp@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
...@@ -76,7 +76,8 @@ class Variated(Base): ...@@ -76,7 +76,8 @@ class Variated(Base):
'_getVariationCategoryList') '_getVariationCategoryList')
def _getVariationCategoryList(self, base_category_list = ()): def _getVariationCategoryList(self, base_category_list = ()):
if base_category_list is (): if base_category_list is ():
base_category_list = self.getVariationRangeBaseCategoryList() base_category_list = self.getVariationBaseCategoryList()
# base_category_list = self.getVariationRangeBaseCategoryList()
return self.getAcquiredCategoryMembershipList(base_category_list, base=1) return self.getAcquiredCategoryMembershipList(base_category_list, base=1)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
...@@ -104,71 +105,83 @@ class Variated(Base): ...@@ -104,71 +105,83 @@ class Variated(Base):
variation_category_item_list.append((current_category,current_category)) variation_category_item_list.append((current_category,current_category))
if base_category_list is (): if base_category_list is ():
base_category_list = self.getVariationRangeBaseCategoryList() base_category_list = self.getVariationBaseCategoryList()
if omit_option_base_category == 1: if omit_option_base_category == 1:
base_category_list = [x for x in base_category_list if x not in base_category_list = [x for x in base_category_list if x not in
self.getPortalOptionBaseCategoryList()] self.getPortalOptionBaseCategoryList()]
for base_category in base_category_list: for base_category in base_category_list:
variation_category_list = self._getVariationCategoryList( variation_category_list = self._getVariationCategoryList(
base_category_list=[base_category]) base_category_list=[base_category])
variation_list = map(lambda x: self.portal_categories.resolveCategory(x), variation_list = [self.portal_categories.resolveCategory(x) for x in \
variation_category_list) variation_category_list]
variation_category_item_list.extend(Renderer( category_list = [x for x in variation_list \
if x.getPortalType() == 'Category']
variation_category_item_list.extend(Renderer(
display_base_category=display_base_category, display_base_category=display_base_category,
display_none_category=0, base=base, display_none_category=0, base=base,
current_category=current_category, current_category=current_category,
display_id=display_id,**kw).\ display_id=display_id, **kw).\
render(variation_list)) render(category_list))
object_list = [x for x in variation_list \
if x.getPortalType() != 'Category']
variation_category_item_list.extend(Renderer(
base_category=base_category,
display_base_category=display_base_category,
display_none_category=0, base=base,
current_category=current_category,
display_id='title', **kw).\
render(object_list))
return variation_category_item_list return variation_category_item_list
def getVariationCategoryTitleOrIdItemList(self, base_category_list=(), base=1, **kw): # XXX Is it used ?
""" # def getVariationCategoryTitleOrIdItemList(self, base_category_list=(),
Returns a list of tuples by parsing recursively all categories in a # base=1, **kw):
given list of base categories. Uses getTitleOrId as method # """
""" # Returns a list of tuples by parsing recursively all categories in a
return self.getVariationCategoryItemList(display_id='title_or_id', base_category_list=base_category_list, base=base, **kw) # given list of base categories. Uses getTitleOrId as method
# """
# return self.getVariationCategoryItemList(
# display_id='title_or_id',
# base_category_list=base_category_list, base=base, **kw)
security.declareProtected(Permissions.ModifyPortalContent, '_setVariationCategoryList') security.declareProtected(Permissions.ModifyPortalContent,
def _setVariationCategoryList(self, node_list, base_category_list = ()): '_setVariationCategoryList')
def _setVariationCategoryList(self, node_list, base_category_list=()):
if base_category_list is (): if base_category_list is ():
base_category_list = self.getVariationRangeBaseCategoryList() base_category_list = self.getVariationBaseCategoryList()
self._setCategoryMembership(base_category_list,node_list,base=1) self._setCategoryMembership(base_category_list,node_list,base=1)
security.declareProtected(Permissions.ModifyPortalContent, 'setVariationCategoryList') security.declareProtected(Permissions.ModifyPortalContent,
def setVariationCategoryList(self, node_list, base_category_list = () ): 'setVariationCategoryList')
self._setVariationCategoryList(node_list, base_category_list = base_category_list) def setVariationCategoryList(self, node_list, base_category_list=()):
self._setVariationCategoryList(node_list,
base_category_list=base_category_list)
self.reindexObject() self.reindexObject()
# Range # Range
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getVariationRangeBaseCategoryList') 'getVariationRangeBaseCategoryList')
def getVariationRangeBaseCategoryList(self): def getVariationRangeBaseCategoryList(self):
""" """
Returns possible variation base_category ids of the Returns possible variation base_category ids.
default resource of this transformation
""" """
try: # Get a portal method which defines a list of
resource = self.getDefaultResourceValue() # variation base category
except AttributeError: return self.getPortalVariationBaseCategoryList()
resource = None
if resource is not None:
result = resource.getVariationBaseCategoryList()
else:
result = self.portal_categories.getBaseCategoryList()
return result
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getVariationRangeBaseCategoryItemList') 'getVariationRangeBaseCategoryItemList')
def getVariationRangeBaseCategoryItemList(self, base=1, display_id='getTitle', current_category=None): def getVariationRangeBaseCategoryItemList(self, base=1,
display_id='getTitle',
current_category=None):
""" """
Returns possible variations of the resource Returns possible variations of the resource
as a list of tuples (id, title). This is mostly as a list of tuples (id, title). This is mostly
useful in ERP5Form instances to generate selection useful in ERP5Form instances to generate selection
menus. menus.
""" """
return self.portal_categories.getItemList(self.getVariationRangeBaseCategoryList()) return self.portal_categories.getItemList(
self.getVariationBaseCategoryList())
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getVariationBaseCategoryItemList') 'getVariationBaseCategoryItemList')
...@@ -191,8 +204,10 @@ class Variated(Base): ...@@ -191,8 +204,10 @@ class Variated(Base):
return result return result
# Methods for matrix UI widgets # Methods for matrix UI widgets
# XXX FIXME Those method are depreciated.
# We now use _asCellRange scripts.
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getLineVariationRangeCategoryItemList') 'getLineVariationRangeCategoryItemList')
def getLineVariationRangeCategoryItemList(self): def getLineVariationRangeCategoryItemList(self):
""" """
Returns possible variations in line Returns possible variations in line
...@@ -202,8 +217,9 @@ class Variated(Base): ...@@ -202,8 +217,9 @@ class Variated(Base):
except AttributeError: except AttributeError:
resource = None resource = None
if resource is not None: if resource is not None:
clist = resource.getVariationRangeCategoryItemList(base_category_list = clist = resource.getVariationRangeCategoryItemList(
self.getVariationBaseCategoryLine(), root=0) base_category_list=self.getVariationBaseCategoryLine(),
root=0)
else: else:
clist = [(None,None)] clist = [(None,None)]
return clist return clist
......
...@@ -103,15 +103,24 @@ class TestTransformation(TestOrderMixin,ERP5TypeTestCase): ...@@ -103,15 +103,24 @@ class TestTransformation(TestOrderMixin,ERP5TypeTestCase):
component_name = component_info['name'] component_name = component_info['name']
component = component_module.newContent() component = component_module.newContent()
component_dict[component_name] = component component_dict[component_name] = component
variation1 = component.newContent(portal_type=self.component_variation_portal_type,id='1') variation1 = component.newContent(
variation2 = component.newContent(portal_type=self.component_variation_portal_type,id='2') portal_type=self.component_variation_portal_type,
id='1')
variation2 = component.newContent(
portal_type=self.component_variation_portal_type,
id='2')
variations = [variation1, variation2] variations = [variation1, variation2]
# Commit and catalog
get_transaction().commit()
self.tic()
component.setPricedQuantity(component_info['quantity']) component.setPricedQuantity(component_info['quantity'])
component.setVariationBaseCategoryList(['variation']) component.setVariationBaseCategoryList(['variation'])
component.setPVariationBaseCategoryList(['variation']) component.setPVariationBaseCategoryList(['variation'])
component.setCategoryList( ['variation/' + x.getRelativeUrl() for x in variations] ) # Variation are automatically acquired if they are individual variation.
# component.setCategoryList(
# ['variation/' + x.getRelativeUrl() for x in variations] )
# Set the price # Set the price
supply_line = component.newContent(portal_type='Supply Line') supply_line = component.newContent(portal_type='Supply Line')
supply_line.edit( mapped_value_property_list = ['base_price'] ) supply_line.edit( mapped_value_property_list = ['base_price'] )
...@@ -122,10 +131,13 @@ class TestTransformation(TestOrderMixin,ERP5TypeTestCase): ...@@ -122,10 +131,13 @@ class TestTransformation(TestOrderMixin,ERP5TypeTestCase):
membership_criterion_category = ['variation/' + x.getRelativeUrl() for x in variations], membership_criterion_category = ['variation/' + x.getRelativeUrl() for x in variations],
base_price = component_prices[0]) base_price = component_prices[0])
else: else:
supply_line.setVariationBaseCategoryList(['variation']) # supply_line.setVariationBaseCategoryList(['variation'])
supply_line.updateCellRange(base_id = 'path') supply_line.updateCellRange(base_id = 'path')
for i in range(2): for i in range(2):
supply_cell = supply_line.newCell('apparel_component_module/%s/%d' % (component.getId(),(i+1)), base_id='path') supply_cell = supply_line.newCell(
'variation/apparel_component_module/%s/%d' % \
(component.getId(),(i+1)),
base_id='path')
supply_cell.edit( supply_cell.edit(
membership_criterion_base_category = ['variation'], membership_criterion_base_category = ['variation'],
membership_criterion_category = ['variation/' + variations[i].getRelativeUrl()], membership_criterion_category = ['variation/' + variations[i].getRelativeUrl()],
......
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