Commit 62206050 authored by Nicolas Delaby's avatar Nicolas Delaby

Enable conversion and/or deferred reporting of Form Printout or OOo Template.

* when Action url is like string:${object_url}/Document_printout
and Document_printout is a Form Printout or OOo Template.
* even format parameter can be passed like:
string:${object_url}/Document_printout?format=pdf
Then pdf will be default format in format list on dialog
reviewed by Jerome

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32291 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3111e37f
......@@ -53,7 +53,9 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""This script fix dialog actions to add an empty dialog for object_print\n
<value> <string encoding="cdata"><![CDATA[
"""This script fix dialog actions to add an empty dialog for object_print\n
actions that does not provide one.\n
"""\n
from Products.PythonScripts.standard import url_quote\n
......@@ -61,15 +63,40 @@ from Products.PythonScripts.standard import url_quote\n
if dialog_category != \'object_print\':\n
return actions.get(dialog_category, [])\n
\n
\n
def addDialogIfNeeded(url):\n
\'\'\'If the action url is not a dialog, we add a generic print dialog.\n
\'\'\'\n
parts = url.split(\'/\')\n
absolute_url = \'/\'.join(parts[:-1])\n
action = parts[-1]\n
action_id = action.split(\'?\')[0]\n
action_list = action.split(\'?\')\n
action_id = action_list[0]\n
form = getattr(context, action_id, None)\n
if not (hasattr(form, \'pt\') and form.pt == \'form_dialog\'):\n
\n
# try to get format parameter if exists\n
if len(action_list) > 1:\n
parameter_list = action.split(\'?\')[1]\n
parameter_tuple_list = [tuple(tuple_parameter.split(\'=\')) for tuple_parameter in parameter_list.split(\'&\')]\n
parameter_kw = dict(parameter_tuple_list)\n
meta_type = getattr(form, \'meta_type\', None)\n
if meta_type in (\'ERP5 Form Printout\', \'ERP5 OOo Template\',):\n
# The target is a Form Printout or OOoTemplate so use dedicated form_dialog to enable\n
# conversion and/or deferred reporting\n
if meta_type == \'ERP5 Form Printout\':\n
base_content_type = getattr(form, form.template).getProperty(\'content_type\')\n
else:\n
base_content_type = form.getProperty(\'content_type\')\n
if parameter_kw.has_key(\'format\'):\n
# if format is passed in action url: remove it\n
format = parameter_kw.pop(\'format\')\n
action = \'%s?%s\' % (action_id, \'&\'.join([\'=\'.join(tuple_parameter) for tuple_parameter in parameter_kw.items()]))\n
url = \'%s/Base_viewOOoPrintDialog?dialog_action_url=%s&base_content_type=%s&field_your_format=%s\' % (\n
context.absolute_url(),\n
url_quote(\'%s/%s\' % (absolute_url, action)),\n
url_quote(base_content_type),\n
url_quote(format))\n
elif not (hasattr(form, \'pt\') and form.pt == \'form_dialog\'):\n
url = \'%s/Base_viewIntermediatePrintDialog?dialog_action_url=%s\' % (\n
context.absolute_url(), url_quote(\'%s/%s\' % (absolute_url, action)))\n
return url\n
......@@ -86,7 +113,9 @@ for ai in print_action_list:\n
new_print_action_list.append( ai_copy )\n
\n
return new_print_action_list\n
</string> </value>
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......
......@@ -60,6 +60,10 @@ if \'?\' in dialog_action_url:\n
else:\n
dialog_action_url = \'%s?form_id=%s\' % (dialog_action_url, form_id)\n
\n
\n
if format:\n
# Add format parameter if not null\n
dialog_action_url += \'&format=%s\' % (format,)\n
return container.REQUEST.RESPONSE.redirect(dialog_action_url)\n
......@@ -73,7 +77,7 @@ return container.REQUEST.RESPONSE.redirect(dialog_action_url)\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>dialog_action_url, form_id=\'\'</string> </value>
<value> <string>dialog_action_url, form_id=\'\', format=None</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -93,7 +97,7 @@ return container.REQUEST.RESPONSE.redirect(dialog_action_url)\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
......@@ -101,6 +105,8 @@ return container.REQUEST.RESPONSE.redirect(dialog_action_url)\n
<tuple>
<string>dialog_action_url</string>
<string>form_id</string>
<string>format</string>
<string>_inplacevar_</string>
<string>_getattr_</string>
<string>container</string>
</tuple>
......@@ -116,6 +122,7 @@ return container.REQUEST.RESPONSE.redirect(dialog_action_url)\n
<value>
<tuple>
<string></string>
<none/>
</tuple>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_redirectToDialogAction</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_deferred_style</string>
<string>your_dialog_action_url</string>
<string>your_base_content_type</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list>
<string>your_format</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_viewOOoPrintDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Base_viewFormPrintoutDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Print</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_deferred_style</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>your_deferred_style</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewDialogFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>enabled</string>
<string>items</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_format</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>your_format</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewDialogFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.Base_getConversionFormatItemList(base_content_type=request.get(\'base_content_type\', request.get(\'field_your_base_content_type\')))</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
884
\ No newline at end of file
891
\ No newline at end of file
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