From 36098e01ccd8cda73c150bc2b6f557240836de2c Mon Sep 17 00:00:00 2001
From: Fabien Morin <fabien@nexedi.com>
Date: Tue, 21 Jul 2009 11:40:45 +0000
Subject: [PATCH] fix some mistakes : - self is not the same than context, use
 context parameter instead - get closest model from the paysheet - condition
 for slice was wrong. if the slice is equal to the base_application, quantity
 is 0

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28123 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/TradeModelLine.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/product/ERP5/Document/TradeModelLine.py b/product/ERP5/Document/TradeModelLine.py
index 91a4825f50..fd8d5f1065 100644
--- a/product/ERP5/Document/TradeModelLine.py
+++ b/product/ERP5/Document/TradeModelLine.py
@@ -160,7 +160,7 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
         # specialise_value
         document = self.getParentValue().getSpecialiseValue()
       business_process_list = document.findSpecialiseValueList(\
-          context=self, portal_type_list=['Business Process'])
+          context=context, portal_type_list=['Business Process'])
       business_process = None
       property_dict = {}
       if len(business_process_list):
@@ -289,7 +289,8 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
       if salary_range is not None and calculation_script is None:
         # slice are used only if there is no script found, in case where a
         # script exist, slice should be handle in it
-        model = self.getParentValue()
+        model = context.getSpecialiseValue() # get the closest model from
+                                             # the paysheet
         cell = model.getCell(salary_range)
         if cell is None:
           raise ValueError("Line '%s' (%s) can't find the cell corresponding"+\
@@ -299,7 +300,7 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
         model_slice_min = cell.getQuantityRangeMin()
         model_slice_max = cell.getQuantityRangeMax()
         base_application = tmp_movement.getQuantity(0.0)
-        if base_application < model_slice_min:
+        if base_application <= model_slice_min:
           # if base_application is not in the slice range, quantity is 0
           tmp_movement.setQuantity(0)
         elif base_application-model_slice_min > 0:
-- 
2.30.9