Commit f3d65904 authored by Romain Courteaud's avatar Romain Courteaud

Modify the meaning of industrial_phase as a variation.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3456 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9d1c0f50
...@@ -118,7 +118,7 @@ class SupplyChain(Path, XMLObject): ...@@ -118,7 +118,7 @@ class SupplyChain(Path, XMLObject):
security.declareProtected(Permissions.View, security.declareProtected(Permissions.View,
'getPreviousProductionSupplyLinkList') 'getPreviousProductionSupplyLinkList')
def getPreviousProductionSupplyLinkList(self, current_supply_link, def getPreviousProductionSupplyLinkList(self, current_supply_link,
recursive=0, recursive=0, all=0,
checked_link_list=None): checked_link_list=None):
""" """
Return the previous SupplyLink which represents a production. Return the previous SupplyLink which represents a production.
...@@ -140,6 +140,7 @@ class SupplyChain(Path, XMLObject): ...@@ -140,6 +140,7 @@ class SupplyChain(Path, XMLObject):
previous_link_list = self.getPreviousSupplyLinkList(current_supply_link) previous_link_list = self.getPreviousSupplyLinkList(current_supply_link)
# Test each link # Test each link
for previous_link in previous_link_list: for previous_link in previous_link_list:
continue_recursivity = 0
# Great, we find a valid one # Great, we find a valid one
if previous_link.isProductionSupplyLink(): if previous_link.isProductionSupplyLink():
transformation_link_list.append(previous_link) transformation_link_list.append(previous_link)
...@@ -150,13 +151,18 @@ class SupplyChain(Path, XMLObject): ...@@ -150,13 +151,18 @@ class SupplyChain(Path, XMLObject):
"Those SupplyLinks are in conflict: %r and %r" %\ "Those SupplyLinks are in conflict: %r and %r" %\
(current_supply_link.getRelativeUrl(),\ (current_supply_link.getRelativeUrl(),\
previous_link.getRelativeUrl()) previous_link.getRelativeUrl())
if all == 1:
continue_recursivity=1
# Reject the current # Reject the current
elif (recursive==1): elif (recursive==1):
continue_recursivity=1
# Continue to browse the chain ?
if continue_recursivity == 1:
# Browse the previous link # Browse the previous link
transformation_link_list.extend( transformation_link_list.extend(
self.getPreviousProductionSupplyLinkList( self.getPreviousProductionSupplyLinkList(
previous_link, previous_link,
recursive=recursive, recursive=recursive, all=all,
checked_link_list=checked_link_list)) checked_link_list=checked_link_list))
# Return result # Return result
return transformation_link_list return transformation_link_list
...@@ -164,7 +170,7 @@ class SupplyChain(Path, XMLObject): ...@@ -164,7 +170,7 @@ class SupplyChain(Path, XMLObject):
security.declareProtected(Permissions.View, security.declareProtected(Permissions.View,
'getPreviousPackingListSupplyLinkList') 'getPreviousPackingListSupplyLinkList')
def getPreviousPackingListSupplyLinkList(self, current_supply_link, def getPreviousPackingListSupplyLinkList(self, current_supply_link,
recursive=0, recursive=0, all=0,
checked_link_list=None, checked_link_list=None,
movement=None): movement=None):
""" """
...@@ -205,12 +211,13 @@ class SupplyChain(Path, XMLObject): ...@@ -205,12 +211,13 @@ class SupplyChain(Path, XMLObject):
return packing_list_link_list return packing_list_link_list
def getPreviousIndustrialPhaseList(self, current_supply_link, method_id, def getPreviousIndustrialPhaseList(self, current_supply_link, method_id,
include_current=0): include_current=0, all=0):
""" """
Return recursively all previous industrial phase. Return recursively all previous industrial phase.
""" """
method = getattr(self, method_id) method = getattr(self, method_id)
previous_supply_link_list = method(current_supply_link, recursive=1) previous_supply_link_list = method(current_supply_link, recursive=1,
all=all)
# Add the current industrial phase # Add the current industrial phase
if (include_current == 1): if (include_current == 1):
previous_supply_link_list.append(current_supply_link) previous_supply_link_list.append(current_supply_link)
...@@ -232,14 +239,16 @@ class SupplyChain(Path, XMLObject): ...@@ -232,14 +239,16 @@ class SupplyChain(Path, XMLObject):
security.declareProtected(Permissions.View, security.declareProtected(Permissions.View,
'getPreviousProductionIndustrialPhaseList') 'getPreviousProductionIndustrialPhaseList')
def getPreviousProductionIndustrialPhaseList(self, current_supply_link): def getPreviousProductionIndustrialPhaseList(self, current_supply_link,
all=0):
""" """
Return recursively all previous industrial phase representing Return recursively all previous industrial phase representing
a production. a production.
""" """
return self.getPreviousIndustrialPhaseList( return self.getPreviousIndustrialPhaseList(
current_supply_link, current_supply_link,
"getPreviousProductionSupplyLinkList") "getPreviousProductionSupplyLinkList",
all=all)
security.declareProtected(Permissions.View, security.declareProtected(Permissions.View,
'getPreviousPackingListIndustrialPhaseList') 'getPreviousPackingListIndustrialPhaseList')
...@@ -253,7 +262,6 @@ class SupplyChain(Path, XMLObject): ...@@ -253,7 +262,6 @@ class SupplyChain(Path, XMLObject):
"getPreviousPackingListSupplyLinkList", "getPreviousPackingListSupplyLinkList",
include_current=1) include_current=1)
# XXX not well implemented (testing)
security.declareProtected(Permissions.View, security.declareProtected(Permissions.View,
'test') 'test')
def test(self, current_supply_link, movement): def test(self, current_supply_link, movement):
......
...@@ -115,14 +115,16 @@ class SupplyLink(Path, XMLObject): ...@@ -115,14 +115,16 @@ class SupplyLink(Path, XMLObject):
result = 1 result = 1
else: else:
# Test if the movement correspond to the resource to produced # Test if the movement correspond to the resource to produced
ind_phase = movement.getIndustrialPhaseValue() ind_phase_list = movement.getIndustrialPhaseValueList()
if ind_phase is not None: if ind_phase_list != []:
# Is this SupplyLink in the route to the previous production node ? # Is this SupplyLink in the route to the previous production node ?
supply_chain = self.getParent() supply_chain = self.getParent()
previous_ind_phase_list =\ previous_ind_phase_list =\
supply_chain.getPreviousProductionIndustrialPhaseList(self) supply_chain.getPreviousProductionIndustrialPhaseList(self)
for ind_phase in ind_phase_list:
if ind_phase in previous_ind_phase_list: if ind_phase in previous_ind_phase_list:
result = 1 result = 1
break
else: else:
# How to delivered raw materials ? # How to delivered raw materials ?
# First dirty implementation... # First dirty implementation...
......
...@@ -205,14 +205,22 @@ class TransformationRule(Rule): ...@@ -205,14 +205,22 @@ class TransformationRule(Rule):
""" """
Create a movement for the previous variation of the produced resource. Create a movement for the previous variation of the produced resource.
""" """
id_count = 1
consumed_movement_dict = {} consumed_movement_dict = {}
parent_movement = applied_rule.getParent() parent_movement = applied_rule.getParent()
# First, calculate the previous variation of the previous resource # Calculate the previous variation
for previous_supply_link in supply_chain.\
getPreviousSupplyLinkList(current_supply_link):
previous_ind_phase_list = supply_chain.\ previous_ind_phase_list = supply_chain.\
getPreviousProductionIndustrialPhaseList(current_supply_link) getPreviousProductionIndustrialPhaseList(previous_supply_link,
for ind_phase_value in previous_ind_phase_list: all=1)
ind_phase = ind_phase_value.getLogicalPath() if previous_ind_phase_list != []:
consumed_mvt_id = "%s_%s" % ("mr", ind_phase_value.getId()) ind_phase_list = [x.getLogicalPath() for x in \
previous_ind_phase_list]
LOG("TransformationRule, _expandConsumedPreviousVariation", 0,
"ind_phase_list: %r" % ind_phase_list)
consumed_mvt_id = "%s_%s" % ("mr", id_count)
id_count += 1
stop_date = parent_movement.getStartDate() stop_date = parent_movement.getStartDate()
consumed_movement_dict[consumed_mvt_id] = { consumed_movement_dict[consumed_mvt_id] = {
'start_date': current_supply_link.getStartDate(stop_date), 'start_date': current_supply_link.getStartDate(stop_date),
...@@ -229,7 +237,7 @@ class TransformationRule(Rule): ...@@ -229,7 +237,7 @@ class TransformationRule(Rule):
"variation_category_list": \ "variation_category_list": \
parent_movement.getVariationCategoryList(), parent_movement.getVariationCategoryList(),
'causality_value': current_supply_link, 'causality_value': current_supply_link,
"industrial_phase": ind_phase} "industrial_phase_list": ind_phase_list}
return consumed_movement_dict return consumed_movement_dict
def _expandConsumedRawMaterials(self, applied_rule, production, def _expandConsumedRawMaterials(self, applied_rule, production,
......
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