From 86e0a009d1a580da3809aa59ed25d54856ed916b Mon Sep 17 00:00:00 2001
From: Roque Porchetto <roque.porchetto@nexedi.com>
Date: Mon, 1 Jul 2019 10:39:03 +0200
Subject: [PATCH] new category for custom actions and try catch in action
 handling

---
 .../action_type/object_jio_js_script.xml      | 85 +++++++++++++++++++
 product/ERP5Type/Core/ActionInformation.py    | 11 ++-
 2 files changed, 92 insertions(+), 4 deletions(-)
 create mode 100644 product/ERP5/bootstrap/erp5_core/PathTemplateItem/portal_categories/action_type/object_jio_js_script.xml

diff --git a/product/ERP5/bootstrap/erp5_core/PathTemplateItem/portal_categories/action_type/object_jio_js_script.xml b/product/ERP5/bootstrap/erp5_core/PathTemplateItem/portal_categories/action_type/object_jio_js_script.xml
new file mode 100644
index 0000000000..424e26cc87
--- /dev/null
+++ b/product/ERP5/bootstrap/erp5_core/PathTemplateItem/portal_categories/action_type/object_jio_js_script.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="Category" module="erp5.portal_type"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_Add_portal_content_Permission</string> </key>
+            <value>
+              <tuple>
+                <string>Assignor</string>
+                <string>Manager</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>_Add_portal_folders_Permission</string> </key>
+            <value>
+              <tuple>
+                <string>Assignor</string>
+                <string>Manager</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>_Copy_or_Move_Permission</string> </key>
+            <value>
+              <tuple>
+                <string>Assignor</string>
+                <string>Manager</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>_Delete_objects_Permission</string> </key>
+            <value>
+              <tuple>
+                <string>Assignor</string>
+                <string>Manager</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>_Modify_portal_content_Permission</string> </key>
+            <value>
+              <tuple>
+                <string>Assignee</string>
+                <string>Assignor</string>
+                <string>Manager</string>
+                <string>Owner</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>categories</string> </key>
+            <value>
+              <tuple>
+                <string>action_type/object_jio_js_script</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>object_jio_js_script</string> </value>
+        </item>
+        <item>
+            <key> <string>portal_type</string> </key>
+            <value> <string>Category</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>object_jio_js_script</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/product/ERP5Type/Core/ActionInformation.py b/product/ERP5Type/Core/ActionInformation.py
index 1db697464a..0312a8cc30 100644
--- a/product/ERP5Type/Core/ActionInformation.py
+++ b/product/ERP5Type/Core/ActionInformation.py
@@ -188,8 +188,11 @@ class CacheableAction(object):
 
   def cook(self, ec):
     param_dict = self.param_dict.copy()
-    action = self.action
-    param_dict['url'] = action is not None and action(ec) or ''
-    icon = self.icon
-    param_dict['icon'] = icon is not None and icon(ec) or ''
+    try:
+      action = self.action
+      param_dict['url'] = action is not None and action(ec) or ''
+      icon = self.icon
+      param_dict['icon'] = icon is not None and icon(ec) or ''
+    except KeyError:
+      pass
     return param_dict
-- 
2.30.9