Commit 4505188c authored by Yoshinori Okuji's avatar Yoshinori Okuji

Apply render_pdf to a default value. Otherwise, the value may not be formatted...

Apply render_pdf to a default value. Otherwise, the value may not be formatted by options to a field. This passes all the tests, but I have not written any additional test to verify that this results better.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26626 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 25118e8d
...@@ -345,6 +345,11 @@ class ODFStrategy(Implicit): ...@@ -345,6 +345,11 @@ class ODFStrategy(Implicit):
element_tree = self._replaceNodeViaPointReference(element_tree=element_tree, field=field) element_tree = self._replaceNodeViaPointReference(element_tree=element_tree, field=field)
return element_tree return element_tree
def _renderField(self, field):
# XXX It looks ugly to use render_pdf to extract text. Probably
# it should be renamed to render_text.
return field.render_pdf(field.get_value('default'))
def _replaceNodeViaPointReference(self, element_tree=None, field=None, iteration_index=0): def _replaceNodeViaPointReference(self, element_tree=None, field=None, iteration_index=0):
"""replace via ODF point reference """replace via ODF point reference
...@@ -352,7 +357,7 @@ class ODFStrategy(Implicit): ...@@ -352,7 +357,7 @@ class ODFStrategy(Implicit):
<text:reference-mark text:name="invoice-date"/> <text:reference-mark text:name="invoice-date"/>
""" """
field_id = field.id field_id = field.id
field_value = field.get_value('default') field_value = self._renderField(field)
value = self._toUnicodeString(field_value) value = self._toUnicodeString(field_value)
# text:reference-mark text:name="invoice-date" # text:reference-mark text:name="invoice-date"
reference_xpath = '//text:reference-mark[@text:name="%s"]' % field_id reference_xpath = '//text:reference-mark[@text:name="%s"]' % field_id
...@@ -380,7 +385,7 @@ class ODFStrategy(Implicit): ...@@ -380,7 +385,7 @@ class ODFStrategy(Implicit):
range reference example: range reference example:
<text:reference-mark-start text:name="week"/>Monday<text:reference-mark-end text:name="week"/> <text:reference-mark-start text:name="week"/>Monday<text:reference-mark-end text:name="week"/>
""" """
field_value = field.get_value('default') field_value = self._renderField(field)
value = self._toUnicodeString(field_value) value = self._toUnicodeString(field_value)
range_reference_xpath = '//text:reference-mark-start[@text:name="%s"]' % field.id range_reference_xpath = '//text:reference-mark-start[@text:name="%s"]' % field.id
reference_list = element_tree.xpath(range_reference_xpath, namespaces=element_tree.nsmap) reference_list = element_tree.xpath(range_reference_xpath, namespaces=element_tree.nsmap)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment