From 848ec7e7bf7760eb6e16a114ea91500ae14d97d8 Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Tue, 2 Feb 2010 14:02:13 +0000
Subject: [PATCH] introduce 'updating_provider' property with that we can
 specify which tester should be used for updating.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32179 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/PropertySheet/DivergenceTester.py | 5 +++++
 product/ERP5/mixin/rule.py                     | 8 +++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/product/ERP5/PropertySheet/DivergenceTester.py b/product/ERP5/PropertySheet/DivergenceTester.py
index 1f1693009f..9530dc3e81 100644
--- a/product/ERP5/PropertySheet/DivergenceTester.py
+++ b/product/ERP5/PropertySheet/DivergenceTester.py
@@ -49,4 +49,9 @@ class DivergenceTester:
        'type'        : 'boolean',
        'default'     : 0,
        'mode'        : 'rw' },
+    {  'id'          : 'updating_provider',
+       'description' : 'Defines whether a divergence tester acts as a updating provider.',
+       'type'        : 'boolean',
+       'default'     : 1,
+       'mode'        : 'rw' },
   )
diff --git a/product/ERP5/mixin/rule.py b/product/ERP5/mixin/rule.py
index d162f95527..9e679cc030 100644
--- a/product/ERP5/mixin/rule.py
+++ b/product/ERP5/mixin/rule.py
@@ -258,7 +258,9 @@ class RuleMixin:
     #  let us imagine the case of a forward rule
     #  ie. what comes in must either go out or has been lost
     divergence_tester_list = self._getDivergenceTesterList()
-    profit_tester_list = self._getDivergenceTesterList()
+    profit_tester_list = divergence_tester_list
+    updating_tester_list = self._getUpdatingTesterList()
+    profit_updating_tester_list = updating_tester_list
     quantity_tester_list = self._getQuantityTesterList()
     compensated_quantity = 0.0
     updatable_movement = None
@@ -288,7 +290,7 @@ class RuleMixin:
           updatable_compensation_movement = decision_movement
           # Not Frozen can be updated
           kw = {}
-          for tester in profit_tester_list:
+          for tester in profit_updating_tester_list:
             if not tester.compare(prevision_movement, decision_movement):
               kw.update(tester.getUpdatablePropertyDict(prevision_movement, decision_movement))
           if kw:
@@ -304,7 +306,7 @@ class RuleMixin:
           updatable_movement = decision_movement
           # Not Frozen can be updated
           kw = {}
-          for tester in divergence_tester_list:
+          for tester in updating_tester_list:
             if not tester.compare(prevision_movement, decision_movement): 
               kw.update(tester.getUpdatablePropertyDict(prevision_movement, decision_movement))
               # XXX-JPS - there is a risk here that quanity is wrongly updated
-- 
2.30.9