From 0977c87c6a4b0af3cf76b76f32597834aa0d558e Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Tue, 5 May 2009 08:55:05 +0000
Subject: [PATCH] Prevent raising an error when value of a ListField is not in
 the item list.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26797 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../portal_skins/erp5_ods_style/form_view.xml          | 10 ++++++++--
 bt5/erp5_ods_style/bt/revision                         |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/bt5/erp5_ods_style/SkinTemplateItem/portal_skins/erp5_ods_style/form_view.xml b/bt5/erp5_ods_style/SkinTemplateItem/portal_skins/erp5_ods_style/form_view.xml
index 6e9ba38b9d..5c31785319 100644
--- a/bt5/erp5_ods_style/SkinTemplateItem/portal_skins/erp5_ods_style/form_view.xml
+++ b/bt5/erp5_ods_style/SkinTemplateItem/portal_skins/erp5_ods_style/form_view.xml
@@ -113,8 +113,14 @@ dQEAAAAA</string> </value>
                                   tal:content="value">\n
                               </text:p>\n
                             <tal:block tal:condition="python: value != \'\'">\n
-                              <text:p tal:condition="item_list"\n
-                                    tal:content="python: [str(i[0]).replace(\'&amp;\', \'\') for i in item_list if i[1] == value][0]">\n
+\n
+                              <text:p tal:condition="item_list">\n
+                                <tal:block tal:define="displayed_value_list python: [str(i[0]).replace(\'&amp;\', \'\') for i in item_list if i[1] == value]">\n
+                                  <tal:block tal:condition="displayed_value_list"\n
+                                             tal:replace="python: displayed_value_list[0]" />\n
+                                  <tal:block tal:condition="not: displayed_value_list"\n
+                                             tal:replace="python: value" />\n
+                                </tal:block>\n
                               </text:p>\n
                             </tal:block>\n
                             <tal:block tal:condition="python: value is None">\n
diff --git a/bt5/erp5_ods_style/bt/revision b/bt5/erp5_ods_style/bt/revision
index 252b382b33..5e78f1eb7e 100644
--- a/bt5/erp5_ods_style/bt/revision
+++ b/bt5/erp5_ods_style/bt/revision
@@ -1 +1 @@
-202
\ No newline at end of file
+203
\ No newline at end of file
-- 
2.30.9