From 46abf781e6fbda4424f73b2399ff40315c0d7a8e Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Wed, 10 Aug 2011 02:42:54 +0200
Subject: [PATCH] Contribution Tool: fallback to Embedded File only if
 necessary

---
 product/ERP5/Tool/ContributionTool.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/product/ERP5/Tool/ContributionTool.py b/product/ERP5/Tool/ContributionTool.py
index 3279aaddfe..e0fcacd9aa 100644
--- a/product/ERP5/Tool/ContributionTool.py
+++ b/product/ERP5/Tool/ContributionTool.py
@@ -197,12 +197,12 @@ class ContributionTool(BaseTool):
 
     portal_type = kw.pop('portal_type', None)
     if not portal_type:
-      if container is None or container.isModuleType():
-        # Guess it with help of portal_contribution_registry
-        portal_type = portal.portal_contribution_registry.findPortalTypeName(
-          filename=filename, content_type=content_type)
-      else:
-        portal_type = 'Embedded File'
+      # Guess it with help of portal_contribution_registry
+      portal_type = portal.portal_contribution_registry.findPortalTypeName(
+        filename=filename, content_type=content_type)
+      if not (container is None or container.isModuleType() or
+              container.getTypeInfo().allowType(portal_type)):
+          portal_type = 'Embedded File'
 
     if container is not None:
       # Simplify things here and return a document immediately
-- 
2.30.9