Commit 26014b17 authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Rafael Monnerat

Apply commit: Disallow any compensation.

From Lukasz Nowak:

1- Compensation is undesired. (51c8a250)

  Raise loudly with message.

2- Disallow any compensation. (3c74ed07)

3- Emit more informative log. (534b2e77)
parent d0a36a0f
...@@ -38,6 +38,7 @@ from Products.ERP5Type.Errors import SimulationError ...@@ -38,6 +38,7 @@ from Products.ERP5Type.Errors import SimulationError
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from Products.ERP5.ExpandPolicy import policy_dict from Products.ERP5.ExpandPolicy import policy_dict
from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList
from pprint import pformat
from zLOG import LOG from zLOG import LOG
...@@ -367,6 +368,9 @@ class RuleMixin(Predicate): ...@@ -367,6 +368,9 @@ class RuleMixin(Predicate):
if quantity: if quantity:
if decision_movement.isFrozen(): if decision_movement.isFrozen():
# Compensate # Compensate
raise NotImplementedError(
'Compensation undesired: decision_movement %s = %s' % (decision_movement.getPath(),
pformat(decision_movement.__dict__), ))
new_movement = decision_movement.asContext(quantity=-quantity) new_movement = decision_movement.asContext(quantity=-quantity)
new_movement.setDelivery(None) new_movement.setDelivery(None)
movement_collection_diff.addNewMovement(new_movement) movement_collection_diff.addNewMovement(new_movement)
...@@ -414,6 +418,12 @@ class RuleMixin(Predicate): ...@@ -414,6 +418,12 @@ class RuleMixin(Predicate):
not_completed_movement = decision_movement not_completed_movement = decision_movement
# Frozen must be compensated # Frozen must be compensated
if not _compare(profit_tester_list, prevision_movement, decision_movement): if not _compare(profit_tester_list, prevision_movement, decision_movement):
raise NotImplementedError(
'Compensation undesired: prevision_movement %s = %s decision_movement %s = %s' % (
prevision_movement.getPath(),
pformat(prevision_movement.__dict__),
decision_movement.getPath(),
pformat(decision_movement.__dict__) ))
new_movement = decision_movement.asContext( new_movement = decision_movement.asContext(
quantity=-decision_movement_quantity) quantity=-decision_movement_quantity)
new_movement.setDelivery(None) new_movement.setDelivery(None)
...@@ -432,6 +442,12 @@ class RuleMixin(Predicate): ...@@ -432,6 +442,12 @@ class RuleMixin(Predicate):
if decision_movement.isFrozen(): if decision_movement.isFrozen():
# Frozen must be compensated # Frozen must be compensated
if not _compare(divergence_tester_list, prevision_movement, decision_movement): if not _compare(divergence_tester_list, prevision_movement, decision_movement):
raise NotImplementedError(
'Compensation undesired: prevision_movement %s = %s decision_movement %s = %s' % (
prevision_movement.getPath(),
pformat(prevision_movement.__dict__),
decision_movement.getPath(),
pformat(decision_movement.__dict__) ))
new_movement = decision_movement.asContext( new_movement = decision_movement.asContext(
quantity=-decision_movement_quantity) quantity=-decision_movement_quantity)
new_movement.setDelivery(None) new_movement.setDelivery(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