From 78758af2ca811e86cf5c970137069f99d5cb9e18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Mon, 28 Sep 2009 12:03:02 +0000
Subject: [PATCH] support limit= parameter in getMovementHistoryList

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29204 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../Resource_zGetMovementHistoryList.xml      | 20 +++++++++++++++++++
 product/ERP5/bootstrap/erp5_core/bt/revision  |  2 +-
 product/ERP5/tests/testInventoryAPI.py        |  9 +++------
 3 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
index d92239cbec..5c08477669 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
@@ -69,6 +69,12 @@
                                   </dictionary>
                                 </value>
                             </item>
+                            <item>
+                                <key> <string>limit_expression</string> </key>
+                                <value>
+                                  <dictionary/>
+                                </value>
+                            </item>
                             <item>
                                 <key> <string>omit_input</string> </key>
                                 <value>
@@ -151,6 +157,7 @@
                             <string>where_expression</string>
                             <string>order_by_expression</string>
                             <string>group_by_expression</string>
+                            <string>limit_expression</string>
                             <string>selection_domain</string>
                             <string>selection_report</string>
                             <string>ignore_variation</string>
@@ -587,6 +594,7 @@
 where_expression\r\n
 order_by_expression\r\n
 group_by_expression\r\n
+limit_expression\r\n
 selection_domain\r\n
 selection_report\r\n
 ignore_variation\r\n
@@ -758,6 +766,12 @@ GROUP BY\n
 ORDER BY\n
   <dtml-var order_by_expression>\n
 </dtml-if>\n
+\n
+<dtml-if limit_expression>\n
+LIMIT\n
+  <dtml-var limit_expression>\n
+</dtml-if>\n
+\n
 ) AS q1\n
 
 
@@ -918,6 +932,12 @@ GROUP BY\n
 ORDER BY\n
   <dtml-var order_by_expression>\n
 </dtml-if>\n
+\n
+<dtml-if limit_expression>\n
+LIMIT\n
+  <dtml-var limit_expression>\n
+</dtml-if>\n
+\n
 ) AS q1\n
 
 
diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision
index 6b94c06e52..f699c94371 100644
--- a/product/ERP5/bootstrap/erp5_core/bt/revision
+++ b/product/ERP5/bootstrap/erp5_core/bt/revision
@@ -1 +1 @@
-1308
\ No newline at end of file
+1309
\ No newline at end of file
diff --git a/product/ERP5/tests/testInventoryAPI.py b/product/ERP5/tests/testInventoryAPI.py
index 563032dec0..5859ee7ce7 100644
--- a/product/ERP5/tests/testInventoryAPI.py
+++ b/product/ERP5/tests/testInventoryAPI.py
@@ -1228,15 +1228,12 @@ class TestMovementHistoryList(InventoryAPITestCase):
           getMovementHistoryList(section_uid=self.section.getUid(),
                                  sort_on=(('title', 'descending'),)) ])
 
-
-  # FIXME: do we want to include it or no ?
   def test_Limit(self):
-    return "is it part of this API ?" # XXX
     getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
-    for q in range(10):
+    for q in range(6):
       self._makeMovement(quantity=1)
-    self.assertEquals(3, len(getMovementHistoryList(list_start=2,
-                                                    list_lines=3)))
+    self.assertEquals(3, len(getMovementHistoryList(limit=3)))
+    self.assertEquals(4, len(getMovementHistoryList(limit=(1, 4))))
   
   def test_SimulationState(self):
     getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
-- 
2.30.9