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