From 34e56446b9bbfb55c28340f154169de3326a189f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 10 Nov 2010 16:42:07 +0000
Subject: [PATCH] support GAP categories without references

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40183 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../Account_getGapItemList.xml                | 62 ++++++++++++++++---
 bt5/erp5_accounting/bt/revision               |  2 +-
 2 files changed, 54 insertions(+), 10 deletions(-)

diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Account_getGapItemList.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Account_getGapItemList.xml
index de26b0f083..a8404f4463 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Account_getGapItemList.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Account_getGapItemList.xml
@@ -60,27 +60,31 @@ categories from all available GAP.\n
 display_cache = {}\n
 def display(x):\n
   if x not in display_cache:\n
-    gap_id = x.getReference() or x.getId()\n
-    display_cache[x] = \'%s - %s\' % (gap_id, x.getShortTitle() or x.getTitle())\n
-  return display_cache[x]\n
+    gap_id = x.getReference()\n
+    if gap_id:\n
+      display_cache[x] = \'%s - %s\' % (gap_id,\n
+                  x.getShortTitle() or x.getTitle())\n
+    else:\n
+      display_cache[x] = x.getIndentedTitle()\n
 \n
-def sort(x,y):\n
-  return cmp(display(x), display(y))\n
+  return display_cache[x]\n
 \n
-def getGapItemList(only_preferred_gap): \n
+def getGapItemList(only_preferred_gap):\n
   ctool = context.getPortalObject().portal_categories\n
   if only_preferred_gap:\n
     gap_root = context.getPortalObject().portal_preferences\\\n
                     .getPreferredAccountingTransactionGap()\n
     if gap_root:\n
       return ctool.resolveCategory(gap_root).getCategoryChildItemList(\n
-        base=False, is_self_excluded=True, display_method=display, sort_method=sort)\n
+        base=False, is_self_excluded=True, display_method=display,\n
+        local_sort_id=(\'int_index\', \'reference\', \'id\'))\n
 \n
-  result = []  \n
+  result = []\n
   for country in ctool.gap.contentValues():\n
     for gap_root in country.contentValues():\n
       result.extend(gap_root.getCategoryChildItemList(\n
-        base=False, is_self_excluded=True, display_method=display, sort_method=sort))\n
+        base=False, is_self_excluded=True, display_method=display,\n
+        local_sort_id=(\'int_index\', \'reference\', \'id\')))\n
   return result\n
 \n
 from Products.ERP5Type.Cache import CachingMethod\n
@@ -104,6 +108,46 @@ return getGapItemList(only_preferred_gap=only_preferred_gap)\n
               <tuple/>
             </value>
         </item>
+        <item>
+            <key> <string>func_code</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>co_argcount</string> </key>
+                        <value> <int>1</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>only_preferred_gap</string>
+                            <string>display_cache</string>
+                            <string>display</string>
+                            <string>getGapItemList</string>
+                            <string>Products.ERP5Type.Cache</string>
+                            <string>CachingMethod</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <tuple>
+                <int>1</int>
+              </tuple>
+            </value>
+        </item>
         <item>
             <key> <string>id</string> </key>
             <value> <string>Account_getGapItemList</string> </value>
diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision
index c585149e2a..b25e64d515 100644
--- a/bt5/erp5_accounting/bt/revision
+++ b/bt5/erp5_accounting/bt/revision
@@ -1 +1 @@
-1383
\ No newline at end of file
+1385
\ No newline at end of file
-- 
2.30.9