Commit 63808e1f authored by Romain Courteaud's avatar Romain Courteaud

Change type_name parameter to portal_type.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3419 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c2c0d3ee
...@@ -75,10 +75,8 @@ class OrderRule(Rule): ...@@ -75,10 +75,8 @@ class OrderRule(Rule):
is expanded. is expanded.
""" """
delivery_line_type = 'Simulation Movement' delivery_line_type = 'Simulation Movement'
# Get the order when we come from # Get the order when we come from
my_order = applied_rule.getDefaultCausalityValue() my_order = applied_rule.getDefaultCausalityValue()
# Only expand if my_order is not None and state is not 'confirmed' # Only expand if my_order is not None and state is not 'confirmed'
if my_order is not None: if my_order is not None:
# Only expand order rule if order not yet confirmed (This is consistent # Only expand order rule if order not yet confirmed (This is consistent
...@@ -95,19 +93,18 @@ class OrderRule(Rule): ...@@ -95,19 +93,18 @@ class OrderRule(Rule):
movement_type_list = applied_rule.getPortalMovementTypeList() movement_type_list = applied_rule.getPortalMovementTypeList()
order_movement_type_list = \ order_movement_type_list = \
applied_rule.getPortalOrderMovementTypeList() applied_rule.getPortalOrderMovementTypeList()
# Calculate existing simulation movement to delete
for movement in applied_rule.contentValues( for movement in applied_rule.contentValues(
filter={'portal_type': movement_type_list}): filter={'portal_type': movement_type_list}):
order_value = movement.getOrderValue(\ order_value = movement.getOrderValue(\
portal_type=order_movement_type_list) portal_type=order_movement_type_list)
if (order_value is None) or\ if (order_value is None) or\
(order_value.hasCellContent()): (order_value.hasCellContent()):
# XXX Make sure this is not deleted if already in delivery # XXX Make sure this is not deleted if already in delivery
applied_rule._delObject(movement.getId()) applied_rule._delObject(movement.getId())
else: else:
existing_uid_list_append(order_value.getUid()) existing_uid_list_append(order_value.getUid())
# Build simulation movement if necessary
for order_movement in my_order.getMovementList(): for order_movement in my_order.getMovementList():
try: try:
if order_movement.getUid() not in existing_uid_list: if order_movement.getUid() not in existing_uid_list:
...@@ -120,32 +117,29 @@ class OrderRule(Rule): ...@@ -120,32 +117,29 @@ class OrderRule(Rule):
# On a cell # On a cell
new_id = "%s_%s" % (order_movement.getParentId(), new_id = "%s_%s" % (order_movement.getParentId(),
order_movement.getId()) order_movement.getId())
# Generate the simulation movement # Generate the simulation movement
# Source, Destination, Quantity, Date, etc. are # Source, Destination, Quantity, Date, etc. are
# acquired from the order and need not to be copied. # acquired from the order and need not to be copied.
new_sim_mvt = applied_rule.newContent( new_sim_mvt = applied_rule.newContent(
type_name=delivery_line_type, portal_type=delivery_line_type,
id=new_id, id=new_id,
order_value=order_movement, order_value=order_movement,
quantity=order_movement.getQuantity(), quantity=order_movement.getQuantity(),
delivery_ratio=1, delivery_ratio=1,
variation_category_list =\
order_movement.getVariationCategoryList(),
deliverable=1,
**kw)
# No acquisition on variation_category_list # No acquisition on variation_category_list
# in this case to prevent user failure # in this case to prevent user failure
variation_category_list = \
order_movement.getVariationCategoryList(),
deliverable=1)
except AttributeError: except AttributeError:
LOG('ERP5: WARNING', 0, \ LOG('ERP5: WARNING', 0,\
'AttributeError during expand on order line %s' \ 'AttributeError during expand on order movement %s'\
% order_line_object.absolute_url()) % order_movement.absolute_url())
# Now we can set the last expand simulation state # Now we can set the last expand simulation state
# to the current state # to the current state
applied_rule.setLastExpandSimulationState(\ applied_rule.setLastExpandSimulationState(\
my_order.getSimulationState()) my_order.getSimulationState())
# Pass to base class # Pass to base class
Rule.expand(self, applied_rule, force=force, **kw) Rule.expand(self, applied_rule, force=force, **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