Commit 67284a67 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_document_scanner: Avoid reference hardcoded in many places

parent cbbe5b44
assert context.getPortalType() == "Active Process", "It must be an Active Process"
assert context.getReference() == "document_scanner_js", "Unexpected reference"
assert context.getReference() == context.Base_getDocumentScannerDefaultReference(), "Unexpected reference"
context.getPortalObject().portal_activities.manage_delObjects(
ids=[context.getId(),])
......@@ -3,7 +3,7 @@ portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type=["Active Process",],
method_id='ActiveProcess_removeItselfFromActivityTool',
reference="document_scanner_js",
reference=context.Base_getDocumentScannerDefaultReference(),
# Active Process don't have creation date set
indexation_timestamp="< %s" % (DateTime()-4).earliestTime(),
modification_date="< %s" % (DateTime()-4).earliestTime(),
)
import json
active_process = context.getPortalObject().portal_activities.newActiveProcess()
active_process = context.getPortalObject().portal_activities.newActiveProcess(
reference=context.Base_getDocumentScannerDefaultReference())
return json.dumps({
"active_process": active_process.getRelativeUrl(),
......
<?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></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getDocumentScannerDefaultReference</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -10,14 +10,15 @@ portal = context.getPortalObject()
if REQUEST:
return RuntimeError("You cannot run this script in the url")
reference = context.Base_getDocumentScannerDefaultReference()
if active_process_url:
active_process = portal.restrictedTraverse(active_process_url)
else:
active_process = portal.portal_activities.newActiveProcess()
active_process.setReference("document_scanner_js")
active_process = portal.portal_activities.newActiveProcess(
reference=reference)
if generate_new_uid:
id_group = ('document_scanner_js', active_process.getUid())
id_group = (reference, active_process.getUid())
new_uid = portal.portal_ids.generateNewId(id_group=id_group, default=0)
else:
new_uid = None
......
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