Commit 5d98d68d authored by Jérome Perrin's avatar Jérome Perrin

reexpand to take into account modified/added delivery movements


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3869 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6bb9ddc7
...@@ -74,26 +74,23 @@ class DeliveryRule(Rule): ...@@ -74,26 +74,23 @@ class DeliveryRule(Rule):
is expanded. is expanded.
""" """
delivery_line_type = 'Simulation Movement' delivery_line_type = 'Simulation Movement'
# Get the delivery when we come from # Get the delivery where we come from
# Causality is a kind of Delivery (ex. Packing List) # Causality is a kind of Delivery (ex. Packing List)
my_delivery = applied_rule.getDefaultCausalityValue() my_delivery = applied_rule.getDefaultCausalityValue()
# Only expand if my_delivery is not None # Only expand if my_delivery is not None
# and state is not 'confirmed'
if my_delivery is not None: if my_delivery is not None:
#if my_delivery.getSimulationState() not in ('delivered', ): #if my_delivery.getSimulationState() not in ('delivered', ):
# Even if delivered, we should always calculate consequences # Even if delivered, we should always calculate consequences
# First, check each contained movement and make # First, check each contained movement and make
# a list of delivery ids which do not need to be copied # a list of delivery uids which do not need to be copied
# eventually delete movement which do not exist anylonger # eventually delete movement which do not exist anylonger
existing_uid_list = [] existing_uid_list = []
existing_uid_list_append = existing_uid_list.append existing_uid_list_append = existing_uid_list.append
movement_type_list = applied_rule.getPortalMovementTypeList()
order_movement_type_list = getattr(applied_rule, order_movement_type_list = getattr(applied_rule,
movement_type_method)() movement_type_method)()
for movement in applied_rule.contentValues( for movement in applied_rule.objectValues() :
filter={'portal_type':movement_type_list}):
delivery_value = movement.getDeliveryValue( delivery_value = movement.getDeliveryValue(
portal_type=order_movement_type_list) portal_type=order_movement_type_list)
...@@ -110,6 +107,8 @@ class DeliveryRule(Rule): ...@@ -110,6 +107,8 @@ class DeliveryRule(Rule):
# Copy each movement (line or cell) from the delivery is that # Copy each movement (line or cell) from the delivery is that
for delivery_movement in my_delivery.getMovementList(): for delivery_movement in my_delivery.getMovementList():
simulation_movement_to_update_list = delivery_movement.\
getOrderRelatedValueList(portal_type = 'Simulation Movement')
try: try:
if len(delivery_movement.getDeliveryRelatedValueList()) == 0: if len(delivery_movement.getDeliveryRelatedValueList()) == 0:
# Only create if orphaned movement # Only create if orphaned movement
...@@ -125,9 +124,13 @@ class DeliveryRule(Rule): ...@@ -125,9 +124,13 @@ class DeliveryRule(Rule):
delivery_movement.getId()) delivery_movement.getId())
# Generate the simulation movement # Generate the simulation movement
new_sim_mvt = applied_rule.newContent( new_sim_mvt = applied_rule.newContent(
portal_type=delivery_line_type, id = new_id,
id=new_id, portal_type = delivery_line_type,
order_value=delivery_movement, order_value = delivery_movement)
simulation_movement_to_update_list.append(new_sim_mvt)
for simulation_movement in simulation_movement_to_update_list :
simulation_movement.edit(
delivery_value=delivery_movement, delivery_value=delivery_movement,
# XXX Do we need to copy the quantity # XXX Do we need to copy the quantity
# Why not the resource, the variation,... # Why not the resource, the variation,...
...@@ -136,10 +139,13 @@ class DeliveryRule(Rule): ...@@ -136,10 +139,13 @@ class DeliveryRule(Rule):
delivery_movement.getVariationCategoryList(), delivery_movement.getVariationCategoryList(),
delivery_ratio=1, delivery_ratio=1,
deliverable=1) deliverable=1)
except AttributeError: except AttributeError:
LOG('ERP5: WARNING', 0, LOG('ERP5: WARNING', 0,
'AttributeError during expand on delivery line %s'\ 'AttributeError during expand on delivery line %s'\
% delivery_movement.absolute_url()) % delivery_movement.absolute_url())
# Pass to base class # Pass to base class
Rule.expand(self, applied_rule, **kw) Rule.expand(self, applied_rule, **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