From d867ec19763e373aac8afcdca3df7df2bca1d526 Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Fri, 16 Apr 2004 10:56:51 +0000
Subject: [PATCH] solve problem when there is a new object equal to none

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@681 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/ListBox.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py
index f0e76241c3..81eb00cd27 100755
--- a/product/ERP5Form/ListBox.py
+++ b/product/ERP5Form/ListBox.py
@@ -37,6 +37,7 @@ from Selection import Selection
 from DateTime import DateTime
 from Products.ERP5Type.Utils import getPath
 from Products.ERP5Type.Document import newTempBase
+from Products.CMFCore.utils import getToolByName
 from xml.sax.saxutils import escape
 from copy import copy
 
@@ -1182,7 +1183,8 @@ class ListBoxValidator(Validator.Validator):
         selection_name = field.get_value('selection_name')
         selection = here.portal_selections.getSelectionFor(selection_name, REQUEST=REQUEST)
         params = selection.getSelectionParams()
-
+        portal_url = getToolByName(here, 'portal_url')
+        portal = portal_url.getPortalObject()
 
         result = {}
         error_result = {}
@@ -1208,6 +1210,10 @@ class ListBoxValidator(Validator.Validator):
             for object in object_list:
               if object.getUid()==uid:
                 o = object
+            if o is None:
+              # First case: dialog input to create new objects
+              o = newTempBase(portal, uid[4:]) # Arghhh - XXX acquisition problem - use portal root
+              o.uid = uid
             listbox[uid[4:]] = {}
             # We first try to set a listbox corresponding to all things 
             # we can validate, so that we can use the same list 
@@ -1246,6 +1252,10 @@ class ListBoxValidator(Validator.Validator):
             for object in object_list:
               if object.getUid()==uid:
                 o = object
+            if o is None:
+              # First case: dialog input to create new objects
+              o = newTempBase(portal, uid[4:]) # Arghhh - XXX acquisition problem - use portal root
+              o.uid = uid
             result[uid[4:]] = {}
             for sql in editable_column_ids:
               alias = '_'.join(sql.split('.'))
-- 
2.30.9