From 6d0b9c92ef942502cd46fa744fa9588a6c2f1e7c Mon Sep 17 00:00:00 2001
From: Alain Takoudjou <talino@tiolive.com>
Date: Fri, 3 Oct 2014 08:48:47 +0000
Subject: [PATCH] Apply commit: Disallow any compensation.

From Lukasz Nowak:

1- Compensation is undesired. (51c8a250ac762ede69e16cbf3afc35e70b08b3bb)

  Raise loudly with message.

2- Disallow any compensation. (3c74ed07bf2fff784a7fad48344fe13a5abd906f)

3- Emit more informative log. (534b2e77ade40bb036c4c041401fabcdad72f5af)
---
 product/ERP5/mixin/rule.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/product/ERP5/mixin/rule.py b/product/ERP5/mixin/rule.py
index aa9a91f90e..b6e0a9ca4e 100644
--- a/product/ERP5/mixin/rule.py
+++ b/product/ERP5/mixin/rule.py
@@ -37,6 +37,7 @@ from Products.ERP5Type.Errors import SimulationError
 from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
 from Products.ERP5.ExpandPolicy import policy_dict
 from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList
+from pprint import pformat
 
 from zLOG import LOG
 
@@ -362,6 +363,9 @@ class RuleMixin(Predicate):
         if quantity:
           if decision_movement.isFrozen():
             # 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.setDelivery(None)
             movement_collection_diff.addNewMovement(new_movement)
@@ -409,6 +413,12 @@ class RuleMixin(Predicate):
             not_completed_movement = decision_movement
           # Frozen must be compensated
           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(
                                 quantity=-decision_movement_quantity)
             new_movement.setDelivery(None)
@@ -427,6 +437,12 @@ class RuleMixin(Predicate):
         if decision_movement.isFrozen():
           # Frozen must be compensated
           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(
                                   quantity=-decision_movement_quantity)
             new_movement.setDelivery(None)
-- 
2.30.9