Commit 27a5ab92 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

fix a bug that FormPrintout.index_html does not work with format argument.

* no need to baseconvert because we already call convertFile.
parent 67487f94
......@@ -298,16 +298,18 @@ class FormPrintout(Implicit, Persistent, RoleManager, Item, PropertyManager):
from Products.ERP5Type.Document import newTempOOoDocument
tmp_ooo = newTempOOoDocument(self, self.title_or_id())
tmp_ooo.edit(data=printout,
base_data=printout,
fname=self.title_or_id(),
source_reference=self.title_or_id(),
content_type=content_type)
tmp_ooo.convertToBaseFormat()
content_type=content_type,
base_content_type=content_type)
mime, data = tmp_ooo.convert(format)
if REQUEST is not None and not batch_mode:
REQUEST.RESPONSE.setHeader('Content-Length', len(data))
REQUEST.RESPONSE.setHeader('Content-type', mime)
REQUEST.RESPONSE.setHeader('Content-disposition',
'attachment;filename="%s.%s"' % (filename, format))
return data
return str(data)
InitializeClass(FormPrintout)
......
......@@ -159,6 +159,11 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
self.assertEqual(request.RESPONSE.getHeader('content-disposition'),
'inline;filename="Foo_viewAsPrintout.odt"')
self._validate(odf_document)
pdf_document = foo_printout.index_html(REQUEST=request, format='pdf')
self.assertEqual(request.RESPONSE.getHeader('content-type'),
'application/pdf')
self.assertEqual(request.RESPONSE.getHeader('content-disposition'),
'attachment;filename="Foo_viewAsPrintout.pdf"')
# 2. Normal case: change the field value and check again the ODF document
test1.setTitle("Changed Title!")
......
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