Commit 1cd2313e authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_document_scanner: Use proxy role as manager where is required

parent 3d2a7a0a
"""
Proxy role as Manager is required here to access getResultList
"""
if REQUEST:
return RuntimeError("You cannot run this script in the url")
image_module = context.getPortalObject().image_module
pdf_data_list = []
for result in active_process.getResultList():
pdf_data_list.append(
image_module.newContent(data=result.detail,
portal_type="Image",
temp_object=True).convert(format="pdf")[1])
return pdf_data_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<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>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>active_process, REQUEST=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getTempImageList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
context.getPortalObject().portal_activities.manage_delObjects(
ids=[active_process.getId(),])
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<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>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>active_process</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_removeActiveProcessFromActivityTool</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -4,23 +4,16 @@ class StringIOWithFileName(StringIO):
filename = "{}.pdf".format(
kw.get("title") or DateTime().strftime('%d-%m-%Y_%Hh%M'))
portal = context.getPortalObject()
pdf_data_list = []
image_module = portal.image_module
active_process = portal.restrictedTraverse(active_process_url)
for result in active_process.getResultList():
pdf_data_list.append(
image_module.newContent(data=result.detail,
portal_type="Image",
temp_object=True).convert(format="pdf")[1])
pdf_data_list = context.Base_getTempImageList(active_process)
pdf_data = context.ERP5Site_mergePDFList(pdf_data_list=pdf_data_list)
file_object = StringIOWithFileName(pdf_data)
doc = context.Base_contribute(file=file_object,
batch_mode=True,
redirect_to_document=False,
follow_up_list=[context.getRelativeUrl(),],
**kw)
......@@ -36,4 +29,4 @@ else:
for action in action_list:
getattr(doc, action)()
portal.portal_activities.manage_delObjects(ids=[active_process.getId(),])
context.Base_removeActiveProcessFromActivityTool(active_process)
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