From 37f77c969ca14fe86e5d5273b478245ba8ff4e6b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Tue, 25 Mar 2008 16:11:04 +0000
Subject: [PATCH] Fix grouping dialog for multiple page selections

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20124 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...TransactionModule_setGroupingReference.xml | 22 +++++++++++++------
 ...nsactionModule_updateGroupingReference.xml |  2 +-
 bt5/erp5_accounting/bt/revision               |  2 +-
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_setGroupingReference.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_setGroupingReference.xml
index 0dd68ecb0c..cbb716e7ef 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_setGroupingReference.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_setGroupingReference.xml
@@ -72,11 +72,17 @@ from ZTUtils import make_query\n
 from ZODB.POSException import ConflictError\n
 portal = context.getPortalObject()\n
 getobject = portal.portal_catalog.getobject\n
+stool = portal.portal_selections\n
 N_ = portal.Base_translateString\n
 psm = N_(\'Nothing matches\')\n
 request = container.REQUEST\n
 precision = request.get(\'precision\', 2)\n
 \n
+# update selected uids \n
+stool.updateSelectionCheckedUidList(\n
+    list_selection_name, uids=uids, listbox_uid=listbox_uid, REQUEST=request)\n
+uids = stool.getSelectionCheckedUidsFor(list_selection_name)\n
+\n
 # XXX when should it be validated ?\n
 if node == \'\':\n
   node = context.REQUEST.get(\'field_your_node\', node)\n
@@ -107,11 +113,6 @@ if uids:\n
 request.set(\'total_selected_amount\', total_selected_amount)\n
 \n
 if update:\n
-  # update selected uids \n
-  portal.portal_selections.updateSelectionCheckedUidList(\n
-            selection_name, uids=uids, listbox_uid=listbox_uid,\n
-            REQUEST=context.REQUEST)\n
-    \n
   request.set(\'portal_status_message\', N_(\'Updated\'))\n
   return context.AccountingTransactionModule_viewGroupingFastInputDialog(request)\n
   \n
@@ -123,6 +124,9 @@ if grouping == \'grouping\':\n
   if grouped_line_list:\n
     psm = N_(\'${grouped_line_count} Lines Grouped\',\n
           mapping=dict(grouped_line_count=len(grouped_line_list)))\n
+\n
+    # make sure nothing will be checked next time\n
+    stool.setSelectionCheckedUidsFor(list_selection_name, [])\n
 \n
     # we check if we can mark some transaction as payed.\n
     transaction_list = {}\n
@@ -174,6 +178,9 @@ else:\n
   \n
   psm = N_(\'${ungrouped_line_count} Lines Ungrouped\',\n
             mapping=dict(ungrouped_line_count=len(ungrouped_line_list)))\n
+\n
+  # make sure nothing will be checked next time\n
+  stool.setSelectionCheckedUidsFor(list_selection_name, [])\n
 \n
 request.set(\'portal_status_message\', psm)\n
 return context.AccountingTransactionModule_viewGroupingFastInputDialog(request)\n
@@ -199,7 +206,7 @@ return context.AccountingTransactionModule_viewGroupingFastInputDialog(request)\
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>uids=[], listbox=None, listbox_uid=[], selection_name=\'\', grouping=\'\', node=\'\', mirror_section=\'\', update=0, **kw</string> </value>
+            <value> <string>uids=[], listbox=None, listbox_uid=[], list_selection_name=\'\', grouping=\'\', node=\'\', mirror_section=\'\', update=0, **kw</string> </value>
         </item>
         <item>
             <key> <string>errors</string> </key>
@@ -228,7 +235,7 @@ return context.AccountingTransactionModule_viewGroupingFastInputDialog(request)\
                             <string>uids</string>
                             <string>listbox</string>
                             <string>listbox_uid</string>
-                            <string>selection_name</string>
+                            <string>list_selection_name</string>
                             <string>grouping</string>
                             <string>node</string>
                             <string>mirror_section</string>
@@ -242,6 +249,7 @@ return context.AccountingTransactionModule_viewGroupingFastInputDialog(request)\
                             <string>context</string>
                             <string>portal</string>
                             <string>getobject</string>
+                            <string>stool</string>
                             <string>N_</string>
                             <string>psm</string>
                             <string>container</string>
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_updateGroupingReference.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_updateGroupingReference.xml
index 208d714e1d..436c03e27e 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_updateGroupingReference.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_updateGroupingReference.xml
@@ -73,7 +73,7 @@ return context.AccountingTransactionModule_setGroupingReference(\n
                         uids=uids,\n
                         listbox=listbox,\n
                         listbox_uid=listbox_uid,\n
-                        selection_name=list_selection_name,\n
+                        list_selection_name=list_selection_name,\n
                         node=node,\n
                         mirror_section=mirror_section,\n
                         update=1)\n
diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision
index 7703a12954..06834d4380 100644
--- a/bt5/erp5_accounting/bt/revision
+++ b/bt5/erp5_accounting/bt/revision
@@ -1 +1 @@
-656
\ No newline at end of file
+657
\ No newline at end of file
-- 
2.30.9