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)
if ind_phase in previous_ind_phase_list: for ind_phase in ind_phase_list:
result = 1 if ind_phase in previous_ind_phase_list:
result = 1
break
else: else:
# How to delivered raw materials ? # How to delivered raw materials ?
# First dirty implementation... # First dirty implementation...
......
...@@ -205,31 +205,39 @@ class TransformationRule(Rule): ...@@ -205,31 +205,39 @@ 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
previous_ind_phase_list = supply_chain.\ for previous_supply_link in supply_chain.\
getPreviousProductionIndustrialPhaseList(current_supply_link) getPreviousSupplyLinkList(current_supply_link):
for ind_phase_value in previous_ind_phase_list: previous_ind_phase_list = supply_chain.\
ind_phase = ind_phase_value.getLogicalPath() getPreviousProductionIndustrialPhaseList(previous_supply_link,
consumed_mvt_id = "%s_%s" % ("mr", ind_phase_value.getId()) all=1)
stop_date = parent_movement.getStartDate() if previous_ind_phase_list != []:
consumed_movement_dict[consumed_mvt_id] = { ind_phase_list = [x.getLogicalPath() for x in \
'start_date': current_supply_link.getStartDate(stop_date), previous_ind_phase_list]
'stop_date': stop_date, LOG("TransformationRule, _expandConsumedPreviousVariation", 0,
"resource": parent_movement.getResource(), "ind_phase_list: %r" % ind_phase_list)
# XXX Is the quantity value correct ? consumed_mvt_id = "%s_%s" % ("mr", id_count)
"quantity": parent_movement.getQuantity(), id_count += 1
"quantity_unit": parent_movement.getQuantityUnit(), stop_date = parent_movement.getStartDate()
"destination_list": (), consumed_movement_dict[consumed_mvt_id] = {
"destination_section_list": (), 'start_date': current_supply_link.getStartDate(stop_date),
"source": production, 'stop_date': stop_date,
"source_section": production_section, "resource": parent_movement.getResource(),
"deliverable": 1, # XXX Is the quantity value correct ?
"variation_category_list": \ "quantity": parent_movement.getQuantity(),
parent_movement.getVariationCategoryList(), "quantity_unit": parent_movement.getQuantityUnit(),
'causality_value': current_supply_link, "destination_list": (),
"industrial_phase": ind_phase} "destination_section_list": (),
"source": production,
"source_section": production_section,
"deliverable": 1,
"variation_category_list": \
parent_movement.getVariationCategoryList(),
'causality_value': current_supply_link,
"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