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