Commit 79e851e7 authored by Romain Courteaud's avatar Romain Courteaud

Bug fix: we can now have multiple industrial phase with the same ID and a

different path.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8375 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a65c3b2f
......@@ -142,7 +142,10 @@ class SupplyLink(Path, XMLObject):
supply_chain = self.getParentValue()
next_industrial_phase_list = \
supply_chain.getNextProductionIndustrialPhaseList(self)
ind_phase_id_list = [x.getId() for x in next_industrial_phase_list]
# XXX GetRelativeUrl copy/paste from transformation
# Code duplication
ind_phase_url_list = [x.getRelativeUrl() \
for x in next_industrial_phase_list]
# Get the transformation to use
applied_rule = movement.getParentValue()
......@@ -151,7 +154,7 @@ class SupplyLink(Path, XMLObject):
# Call getAggregatedAmountList
amount_list = transformation.getAggregatedAmountList(
movement.getParentValue().getParentValue(),
ind_phase_id_list=ind_phase_id_list)
ind_phase_url_list=ind_phase_url_list)
resource_list = [x.getResourceValue() for x in amount_list]
current_resource = movement.getResourceValue()
if current_resource not in resource_list:
......
......@@ -95,6 +95,24 @@ class Transformation(XMLObject, Predicate, Variated):
for transformation_line in transformation_line_list:
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,
'getVariationRangeBaseCategoryItemList')
def getVariationRangeBaseCategoryItemList(self,display_id='title_or_id',**kw):
......@@ -206,7 +224,7 @@ class Transformation(XMLObject, Predicate, Variated):
security.declareProtected(Permissions.AccessContentsInformation,
'getAggregatedAmountList')
def getAggregatedAmountList(self, context=None, REQUEST=None,
ind_phase_id_list=None,
ind_phase_url_list=None,
rejected_resource_uid_list=None,
context_quantity=0,**kw):
"""
......@@ -231,11 +249,14 @@ class Transformation(XMLObject, Predicate, Variated):
for transformation in ([self]+template_transformation_list):
transformation_line_list.extend(transformation.objectValues())
# Get only lines related to a precise industrial_phase
if ind_phase_id_list is not None:
transformation_line_list = filter(
lambda x: x.getIndustrialPhaseId() in\
ind_phase_id_list,
transformation_line_list)
if ind_phase_url_list is not None:
new_transf_line_list = []
for line in transformation_line_list:
ind_ph = line.getIndustrialPhaseValue()
if ind_ph is not None:
if ind_ph.getRelativeUrl() in ind_phase_url_list:
new_transf_line_list.append(line)
transformation_line_list = new_transf_line_list
# Filter lines with resource we do not want to see
if rejected_resource_uid_list is not None:
transformation_line_list = filter(
......
......@@ -276,13 +276,13 @@ class TransformationRule(Rule):
# Calculate the industrial phase list
previous_ind_phase_list = supply_chain.\
getPreviousPackingListIndustrialPhaseList(current_supply_link)
ind_phase_id_list = [x.getId() for x in previous_ind_phase_list]
ind_phase_id_list = [x.getRelativeUrl() for x in previous_ind_phase_list]
# Call getAggregatedAmountList
# XXX expand failed if transformation is not defined.
# Do we need to catch the exception ?
amount_list = transformation.getAggregatedAmountList(
tmp_context,
ind_phase_id_list=ind_phase_id_list)
ind_phase_url_list=ind_phase_id_list)
# Add entries in the consumed_movement_dict
consumed_movement_dict = {}
for amount in amount_list:
......
......@@ -227,7 +227,8 @@ class TransformationSourcingRule(Rule):
}
})
# Build the movement
self._buildMovementList(applied_rule, movement_dict,activate_kw=activate_kw)
self._buildMovementList(applied_rule, movement_dict,
activate_kw=activate_kw)
# Create one submovement which sources the transformation
Rule.expand(self, applied_rule, activate_kw=activate_kw, **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