diff --git a/product/ERP5OOo/FormPrintout.py b/product/ERP5OOo/FormPrintout.py index bf99dc98114abe9f75ac62ba1962295ff0df5ecb..32b522f73eaeb677540a37d20ba614c9d4a82ce2 100644 --- a/product/ERP5OOo/FormPrintout.py +++ b/product/ERP5OOo/FormPrintout.py @@ -475,7 +475,7 @@ class ODFStrategy(Implicit): if len(image_list) is 0: return element_tree path = image_field.get_value('default') - picture = self.getPortalObject().unrestrictedTraverse(path) + picture = self.getPortalObject().restrictedTraverse(path) picture_data = getattr(aq_base(picture), 'data', None) picture_type = picture.getContentType() picture_path = self._createOdfUniqueFileName(path=path, picture_type=picture_type) @@ -741,7 +741,9 @@ class ODFStrategy(Implicit): def _toUnicodeString(self, field_value = None): value = '' - if field_value is not None: + if isinstance(field_value, unicode): + value = field_value + elif field_value is not None: value = unicode(str(field_value), 'utf-8') return value diff --git a/product/ERP5OOo/tests/testFormPrintout.py b/product/ERP5OOo/tests/testFormPrintout.py index 7f630edc005ca54d912e9888384bfcf3686bc05b..1f07f37db91f39266b82927941a94c1b2d508113 100644 --- a/product/ERP5OOo/tests/testFormPrintout.py +++ b/product/ERP5OOo/tests/testFormPrintout.py @@ -181,6 +181,14 @@ class TestFormPrintout(ERP5TypeTestCase): builder = OOoBuilder(odf_document) content_xml = builder.extract("content.xml") self.assertTrue(content_xml.find("Français") > 0) + + # 6. Normal case: unicode string + test1.setTitle(u'Français test2') + odf_document = foo_printout() + self.assertTrue(odf_document is not None) + builder = OOoBuilder(odf_document) + content_xml = builder.extract("content.xml") + self.assertTrue(content_xml.find("Français test2") > 0) def test_02_Table_01_Normal(self, run=run_all_test): """To test listbox and ODF table mapping