From 9085381f1a9e187c4f5e0534273e5fc0518a2c1b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Tue, 27 Feb 2007 09:07:37 +0000
Subject: [PATCH] AccountingTransactionModule_setGroupingReference:  * stay on
 the form after grouping  * reset selection when grouping is successful  * fix
 operator priority problem that failed when    
 getDestinationInventoriatedTotalAssetPrice returns None

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13066 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...TransactionModule_setGroupingReference.xml | 19 ++++++++++++-------
 bt5/erp5_accounting_l10n_fr_m9/bt/revision    |  2 +-
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_setGroupingReference.xml b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_setGroupingReference.xml
index faf25f8a30..bc275b5bf6 100644
--- a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_setGroupingReference.xml
+++ b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_setGroupingReference.xml
@@ -68,7 +68,8 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>"""\n
+            <value> <string>"""Set grouping reference for selected lines.\n
+Used as a fast input dialog action.\n
 """\n
 from ZTUtils import make_query\n
 from ZODB.POSException import ConflictError\n
@@ -76,9 +77,9 @@ portal = context.getPortalObject()\n
 getobject = portal.portal_catalog.getobject\n
 N_ = portal.Base_translateString\n
 psm = N_(\'Nothing matches\')\n
+reset = 0\n
 precision = context.REQUEST.get(\'precision\', 2)\n
 \n
-\n
 # XXX when should it be validated ?\n
 if node == \'\':\n
   node = context.REQUEST.get(\'field_your_node\', node)\n
@@ -108,9 +109,9 @@ if update:\n
     for uid in uids:\n
       line = getobject(uid)\n
       if line.AccountingTransaction_isSourceView(): # XXX not optimal !\n
-        total_selected_amount += line.getSourceInventoriatedTotalAssetPrice() or 0\n
+        total_selected_amount += (line.getSourceInventoriatedTotalAssetPrice() or 0)\n
       else:\n
-        total_selected_amount += line.getDestinationInventoriatedTotalAssetPrice() or 0\n
+        total_selected_amount += (line.getDestinationInventoriatedTotalAssetPrice() or 0)\n
         \n
   psm = N_(\'Updated\')\n
   return context.REQUEST.RESPONSE.redirect(\n
@@ -130,7 +131,8 @@ if grouping:\n
   if grouped_line_list:\n
     psm = N_(\'${grouped_line_count} grouped.\',\n
           mapping=dict(grouped_line_count=len(grouped_line_list)))\n
-    \n
+    reset = 1\n
+\n
     # we check if we can mark some transaction as payed.\n
     transaction_list = {}\n
     for line in grouped_line_list:\n
@@ -175,12 +177,12 @@ else:\n
       key = (line.getSource(), line.getDestinationSection())\n
       amount = amount_per_node_mirror_section.get(key, 0)\n
       amount_per_node_mirror_section[key] = amount +\\\n
-                          line.getSourceInventoriatedTotalAssetPrice() or 0\n
+                          (line.getSourceInventoriatedTotalAssetPrice() or 0)\n
     else:\n
       key = (line.getDestination(), line.getSourceSection())\n
       amount = amount_per_node_mirror_section.get(key, 0)\n
       amount_per_node_mirror_section[key] = amount +\\\n
-                      line.getDestinationInventoriatedTotalAssetPrice() or 0\n
+                     (line.getDestinationInventoriatedTotalAssetPrice() or 0)\n
   \n
   valid = 1\n
   for node_mirror_section, amount in amount_per_node_mirror_section.items():\n
@@ -196,6 +198,7 @@ else:\n
   if valid:\n
     psm = N_(\'${ungrouped_line_count} ungrouped.\',\n
           mapping=dict(ungrouped_line_count=len(uids)))\n
+    reset = 1\n
     for line in line_list:\n
       line.AccountingTransactionLine_setGroupingReference(None)\n
   else:\n
@@ -208,6 +211,7 @@ context.REQUEST.RESPONSE.redirect(\n
                           grouping=grouping,\n
                           mirror_section=mirror_section,\n
                           cancel_url=cancel_url,\n
+                          reset=reset,\n
                           portal_status_message=psm))))\n
 </string> </value>
         </item>
@@ -277,6 +281,7 @@ context.REQUEST.RESPONSE.redirect(\n
                             <string>getobject</string>
                             <string>N_</string>
                             <string>psm</string>
+                            <string>reset</string>
                             <string>precision</string>
                             <string>dict</string>
                             <string>total_selected_amount</string>
diff --git a/bt5/erp5_accounting_l10n_fr_m9/bt/revision b/bt5/erp5_accounting_l10n_fr_m9/bt/revision
index eb13855b7d..e3f1e9b791 100644
--- a/bt5/erp5_accounting_l10n_fr_m9/bt/revision
+++ b/bt5/erp5_accounting_l10n_fr_m9/bt/revision
@@ -1 +1 @@
-79
\ No newline at end of file
+80
\ No newline at end of file
-- 
2.30.9