Commit 28472789 authored by Romain Courteaud's avatar Romain Courteaud

Do not modify simulation after "planned" state, as we want to manage causality.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11310 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f170f4e3
......@@ -90,7 +90,8 @@ class DeliveryRule(Rule):
# Check existing movements
for movement in applied_rule.contentValues(portal_type=movement_type):
if movement.getLastExpandSimulationState() in \
delivery.getPortalDraftOrderStateList():
(delivery.getPortalDraftOrderStateList() + \
delivery.getPortalPlannedOrderStateList()):
movement_delivery = movement.getDeliveryValue()
if not self._isTreeDelivered([movement], ignore_first=1) and \
movement_delivery not in delivery_movement_list:
......@@ -102,52 +103,52 @@ class DeliveryRule(Rule):
immutable_movement_list.append(movement)
# Create or modify movements
for movement in delivery.getMovementList():
related_delivery = movement.getDeliveryRelatedValue()
if related_delivery is None:
# create a new movement
if movement.getParentUid() == movement.getExplanationUid():
for deliv_mvt in delivery.getMovementList():
sim_mvt = deliv_mvt.getDeliveryRelatedValue()
if sim_mvt is None:
# create a new deliv_mvt
if deliv_mvt.getParentUid() == deliv_mvt.getExplanationUid():
# We are on a line
new_id = movement.getId()
new_id = deliv_mvt.getId()
else:
# Weare on a cell
new_id = "%s_%s" % (movement.getParentId(), movement.getId())
# Generate the simulation movement
new_id = "%s_%s" % (deliv_mvt.getParentId(), deliv_mvt.getId())
# Generate the simulation deliv_mvt
new_sim_mvt = applied_rule.newContent(
portal_type=movement_type,
id=new_id,
order_value=movement,
order_value=deliv_mvt,
order_ratio=1,
delivery_value=movement,
delivery_value=deliv_mvt,
delivery_ratio=1,
deliverable=1,
source=movement.getSource(),
source_section=movement.getSourceSection(),
destination=movement.getDestination(),
destination_section=movement.getDestinationSection(),
quantity=movement.getQuantity(),
resource=movement.getResource(),
variation_category_list=movement.getVariationCategoryList(),
variation_property_dict=movement.getVariationPropertyDict(),
start_date=movement.getStartDate(),
stop_date=movement.getStopDate())
elif related_delivery in existing_movement_list:
if related_delivery not in immutable_movement_list:
source=deliv_mvt.getSource(),
source_section=deliv_mvt.getSourceSection(),
destination=deliv_mvt.getDestination(),
destination_section=deliv_mvt.getDestinationSection(),
quantity=deliv_mvt.getQuantity(),
resource=deliv_mvt.getResource(),
variation_category_list=deliv_mvt.getVariationCategoryList(),
variation_property_dict=deliv_mvt.getVariationPropertyDict(),
start_date=deliv_mvt.getStartDate(),
stop_date=deliv_mvt.getStopDate())
elif sim_mvt in existing_movement_list:
if sim_mvt not in immutable_movement_list:
# modification allowed
related_delivery.edit(
delivery_value=movement,
sim_mvt.edit(
delivery_value=deliv_mvt,
delivery_ratio=1,
deliverable=1,
source=movement.getSource(),
source_section=movement.getSourceSection(),
destination=movement.getDestination(),
destination_section=movement.getDestinationSection(),
quantity=movement.getQuantity(),
resource=movement.getResource(),
variation_category_list=movement.getVariationCategoryList(),
variation_property_dict=movement.getVariationPropertyDict(),
start_date=movement.getStartDate(),
stop_date=movement.getStopDate(),
source=deliv_mvt.getSource(),
source_section=deliv_mvt.getSourceSection(),
destination=deliv_mvt.getDestination(),
destination_section=deliv_mvt.getDestinationSection(),
quantity=deliv_mvt.getQuantity(),
resource=deliv_mvt.getResource(),
variation_category_list=deliv_mvt.getVariationCategoryList(),
variation_property_dict=deliv_mvt.getVariationPropertyDict(),
start_date=deliv_mvt.getStartDate(),
stop_date=deliv_mvt.getStopDate(),
force_update=1)
else:
# modification disallowed, must compensate
......
......@@ -116,12 +116,14 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
delivery = simulation_movement.getDeliveryValue()
if delivery is not None:
resource = delivery.getProperty('price_currency', None)
if simulation_movement.getParentValue().getParentValue() \
== portal_simulation :
if (resource is not None) and \
(simulation_movement.getParentValue().getParentValue() \
== portal_simulation) :
# we are on the first simulation movement, we'll try
# to get the resource from it's order price currency.
order = simulation_movement.getOrderValue()
resource = order.getProperty('price_currency', None)
if order is not None:
resource = order.getProperty('price_currency', None)
simulation_movement = simulation_movement\
.getParentValue().getParentValue()
if resource is None :
......
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