From 15fffb628ff2907bac0a71998dc0f3eaa742cb3d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Mon, 29 Oct 2007 16:53:55 +0000
Subject: [PATCH] Also handle items if value is not a list. This is for
 ListField support

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17258 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_odt_style/report_view.xml            | 22 +++++++++++++------
 bt5/erp5_odt_style/bt/revision                |  2 +-
 .../erp5_pdf_style/report_view.xml            | 17 +++++++++++---
 bt5/erp5_pdf_style/bt/revision                |  2 +-
 4 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/bt5/erp5_odt_style/SkinTemplateItem/portal_skins/erp5_odt_style/report_view.xml b/bt5/erp5_odt_style/SkinTemplateItem/portal_skins/erp5_odt_style/report_view.xml
index ae9b98c8e7..6a45ab8d58 100644
--- a/bt5/erp5_odt_style/SkinTemplateItem/portal_skins/erp5_odt_style/report_view.xml
+++ b/bt5/erp5_odt_style/SkinTemplateItem/portal_skins/erp5_odt_style/report_view.xml
@@ -245,11 +245,12 @@ bWxQSwUGAAAAAAIAAgCeAAAAhwwAAAAA</string> </value>
                            <table:table-cell table:style-name=\'field-table.B1\' office:value-type=\'string\'\n
                                              tal:define="value python: field.get_value(\'default\')">\n
                             <tal:block tal:condition="python: same_type(value,[]) or same_type(value,())">\n
-                              <tal:block tal:condition="python: field.has_value(\'items\')"\n
-                                         tal:define="field_item_dict python:dict([(x[1], x[0]) for x in field.get_value(\'items\')]);">\n
-                               <tal:block tal:repeat="item value">\n
-                                 <text:p text:style-name=\'field-content\'\n
+                              <tal:block tal:condition="python: field.has_value(\'items\')">\n
+                                <tal:block tal:define="field_item_dict python:dict([(x[1], x[0]) for x in field.get_value(\'items\')]);">\n
+                                 <tal:block tal:repeat="item value">\n
+                                   <text:p text:style-name=\'field-content\'\n
                                          tal:content="python: field_item_dict.get(item, \'??? (%s)\' % item)"/>\n
+                                 </tal:block>\n
                                </tal:block>\n
                               </tal:block>\n
                               <tal:block tal:condition="python: not field.has_value(\'items\')">\n
@@ -259,9 +260,16 @@ bWxQSwUGAAAAAAIAAgCeAAAAhwwAAAAA</string> </value>
                                </tal:block>\n
                               </tal:block>\n
                            </tal:block>\n
-                            <tal:block tal:condition="python: not (same_type(value, []) or same_type(value, ()))">\n
-                              <text:p text:style-name=\'field-content\' tal:content="python: field.render_pdf(value)" />\n
-                            </tal:block>\n
+                           <tal:block tal:condition="python: not (same_type(value, []) or same_type(value, ()))">\n
+                             <tal:block tal:condition="python: field.has_value(\'items\')">\n
+                               <tal:block tal:define="field_item_dict python:dict([(x[1], x[0]) for x in field.get_value(\'items\')]);">                             \n
+                                 <text:p text:style-name=\'field-content\' tal:content="python: field_item_dict.get(value, \'??? (%s)\' % value)"/>\n
+                               </tal:block>\n
+                             </tal:block>\n
+                             <tal:block tal:condition="python: not field.has_value(\'items\')">\n
+                               <text:p text:style-name=\'field-content\' tal:content="python: field.render_pdf(value)" />\n
+                             </tal:block>\n
+                           </tal:block>\n
                            </table:table-cell>\n
                           </table:table-row>\n
                          </tal:block>\n
diff --git a/bt5/erp5_odt_style/bt/revision b/bt5/erp5_odt_style/bt/revision
index da2d3988d7..3f10ffe7a4 100644
--- a/bt5/erp5_odt_style/bt/revision
+++ b/bt5/erp5_odt_style/bt/revision
@@ -1 +1 @@
-14
\ No newline at end of file
+15
\ No newline at end of file
diff --git a/bt5/erp5_pdf_style/SkinTemplateItem/portal_skins/erp5_pdf_style/report_view.xml b/bt5/erp5_pdf_style/SkinTemplateItem/portal_skins/erp5_pdf_style/report_view.xml
index 83876a996e..a960600673 100644
--- a/bt5/erp5_pdf_style/SkinTemplateItem/portal_skins/erp5_pdf_style/report_view.xml
+++ b/bt5/erp5_pdf_style/SkinTemplateItem/portal_skins/erp5_pdf_style/report_view.xml
@@ -85,13 +85,14 @@
                   </td>\n
                   <td tal:attributes="colwidth python: None" tal:define="value python: field.get_value(\'default\')">\n
                     <tal:block tal:condition="python: same_type(value,[]) or same_type(value,())">\n
-                      <tal:block tal:condition="python: field.has_value(\'items\')"\n
-                                 tal:define="field_item_dict python:dict([(x[1], x[0]) for x in field.get_value(\'items\')]);">\n
+                    <tal:block tal:condition="python: field.has_value(\'items\')">\n
+                      <tal:block tal:define="field_item_dict python:dict([(x[1], x[0]) for x in field.get_value(\'items\')]);">\n
                          <tal:block tal:repeat="item value">\n
                            <para style="TableStandard"\n
                                  tal:content="python: field_item_dict.get(item, \'??? (%s)\' % item)"/>\n
                          </tal:block>\n
                        </tal:block>\n
+                      </tal:block>\n
                       <tal:block tal:condition="python: not field.has_value(\'items\')">\n
                         <tal:block tal:repeat="item value">\n
                           <para  style="TableStandard" tal:content="python: str(item)" />\n
@@ -99,7 +100,17 @@
                       </tal:block>\n
                     </tal:block>\n
                     <tal:block tal:condition="python: not (same_type(value, []) or same_type(value, ()) or same_type(value, None))">\n
-                      <para  style="TableStandard" tal:content="python: field.render_pdf(value)" />\n
+                     <tal:block tal:condition="python: field.has_value(\'items\')">\n
+                      <tal:block tal:define="field_item_dict python:dict([(x[1], x[0]) for x in field.get_value(\'items\')]);">\n
+                        <!-- field.render_pdf should do this. Also the check field.has_value is wrong with RelationFields.\n
+                             Fortunatly we don\'t use them in reports for now --> \n
+                         <para style="TableStandard"\n
+                               tal:content="python: field_item_dict.get(value, \'??? (%s)\' % value)"/>\n
+                       </tal:block>\n
+                     </tal:block>\n
+                      <tal:block tal:condition="python: not field.has_value(\'items\')">\n
+                        <para  style="TableStandard" tal:content="python: field.render_pdf(value)" />\n
+                      </tal:block>\n
                     </tal:block>\n
                     <tal:block tal:condition="python: value is None">\n
                       <para  style="TableStandard" tal:content="python: \' \'" />\n
diff --git a/bt5/erp5_pdf_style/bt/revision b/bt5/erp5_pdf_style/bt/revision
index c5b431b6cb..7003e7fe1f 100644
--- a/bt5/erp5_pdf_style/bt/revision
+++ b/bt5/erp5_pdf_style/bt/revision
@@ -1 +1 @@
-50
\ No newline at end of file
+51
\ No newline at end of file
-- 
2.30.9