diff --git a/product/ERP5OOo/FormPrintout.py b/product/ERP5OOo/FormPrintout.py index 61c0d51b4d5bb5ff7758b232c2b40a9e85bee876..990ad5a00eed21a458971234df7f10da91d97af9 100644 --- a/product/ERP5OOo/FormPrintout.py +++ b/product/ERP5OOo/FormPrintout.py @@ -150,7 +150,7 @@ class FormPrintout(Implicit, Persistent, RoleManager, Item): self.form_name = form_name self.template = template - security.declareProtected('View management screens', 'index_html') + security.declareProtected('View', 'index_html') def index_html(self, icon=0, preview=0, width=None, height=None, REQUEST=None): """Render and view a printout document.""" @@ -178,14 +178,14 @@ class FormPrintout(Implicit, Persistent, RoleManager, Item): content_type = printout_template.content_type self.strategy = self._createStrategy(content_type) printout = self.strategy.render(extra_context=extra_context) - REQUEST.RESPONSE.setHeader('Content-Type','%s; charset=utf-8' % content_type) - REQUEST.RESPONSE.setHeader('Content-disposition', - 'inline;filename="%s%s"' % (self.title_or_id(), guess_extension(content_type))) + if REQUEST is not None: + REQUEST.RESPONSE.setHeader('Content-Type','%s; charset=utf-8' % content_type) + REQUEST.RESPONSE.setHeader('Content-disposition', + 'inline;filename="%s%s"' % (self.title_or_id(), guess_extension(content_type))) return printout - security.declareProtected('View', '__call__') - def __call__(self, *args, **kwargs): - return self.index_html(REQUEST=get_request()) + security.declareProtected('View', '__call__') + __call__ = index_html security.declareProtected('Manage properties', 'doSettings') def doSettings(self, REQUEST, title='', form_name='', template=''): diff --git a/product/ERP5OOo/tests/testFormPrintout.py b/product/ERP5OOo/tests/testFormPrintout.py index 4042dbf3788e9578e54e130a839d2c0532cbc213..ab5155bae56e0fa0c5f05f27e7253912c3f9f3c2 100644 --- a/product/ERP5OOo/tests/testFormPrintout.py +++ b/product/ERP5OOo/tests/testFormPrintout.py @@ -162,6 +162,8 @@ class TestFormPrintout(ERP5TypeTestCase): builder = OOoBuilder(odf_document) content_xml = builder.extract("content.xml") self.assertTrue(content_xml.find("call!") > 0) + # when just call FormPrintout, it does not set content-type + self.assertEqual(request.RESPONSE.getHeader('Content-Type'), None) # 5. Normal case: utf-8 string test1.setTitle("Français")