From c3c0578e16040d181c463890d38175140c907ebd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Thu, 22 Dec 2005 12:41:13 +0000
Subject: [PATCH] sort action's priority also for old format

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4853 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/BusinessTemplate.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py
index b557f71a72..929c67a5da 100755
--- a/product/ERP5/Document/BusinessTemplate.py
+++ b/product/ERP5/Document/BusinessTemplate.py
@@ -1389,7 +1389,7 @@ class ActionTemplateItem(ObjectTemplateItem):
                       , optional = getattr(action, 'optional', 0)
                       , priority = action.priority
                     )
-          # sort action now
+          # sort action based on the priority define on it
           # XXX suppose that priority are properly on actions
           new_priority = action.priority
           action_list = obj.listActions()
@@ -1420,6 +1420,15 @@ class ActionTemplateItem(ObjectTemplateItem):
                     , icon = getattr(action, 'icon', None) and action.icon.text or ''
                     , optional = getattr(action, 'optional', 0)
                     )
+          new_priority = action.priority
+          action_list = obj.listActions()
+          move_down_list = []
+          for index in range(len(action_list)):
+            action = action_list[index]
+            if action.priority > new_priority:
+              move_down_list.append(str(index))
+          obj.moveDownActions(selections=tuple(move_down_list))
+
 
   def uninstall(self, context, **kw):
     p = context.getPortalObject()
-- 
2.30.9