From 02327264c3a93180b53bac45d5203eb1ab651f9a Mon Sep 17 00:00:00 2001
From: Yoshinori Okuji <yo@nexedi.com>
Date: Tue, 14 Jun 2005 11:47:35 +0000
Subject: [PATCH] Fix a bug in calculating the start... this works, but I do
 not like this, because this is dirty. But anyway ListBox is entirely dirty.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3253 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/ListBox.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py
index a26958c1a3..5a2dd7d094 100755
--- a/product/ERP5Form/ListBox.py
+++ b/product/ERP5Form/ListBox.py
@@ -1021,15 +1021,17 @@ class ListBoxWidget(Widget.Widget):
             if count_method is not None and not selection.invert_mode:
               #LOG('ListBox', 0, 'use count_method %r' % count_method)
               # If the count method is available, get only required objects.
-              kw['limit'] = (start, lines)
-              selection.edit( params = kw, report = None )
-              object_list = selection(method = list_method, context=here, REQUEST=REQUEST)
-              del kw['limit']
               selection.edit( params = kw, report = None )
               count = selection(method = count_method, context=here, REQUEST=REQUEST)
               object_list_len = int(count[0][0])
               if start > object_list_len:
                 start = object_list_len
+              start -= (start % lines)
+              kw['limit'] = (start, lines)
+              selection.edit( params = kw, report = None )
+              object_list = selection(method = list_method, context=here, REQUEST=REQUEST)
+              del kw['limit']
+              selection.edit( params = kw, report = None ) # XXX Necessary?
               # For convenience, add padding into the list of objects with None.
               object_list = [None] * start + list(object_list) + [None] * (object_list_len - len(object_list) - start)
             else:
-- 
2.30.9