Commit 46b35ed9 authored by Romain Courteaud's avatar Romain Courteaud

Do not create internal packing list when adding a Computer.

Their creation should not be synchronous but alarm based instead.
parent 4d2ca8b5
......@@ -51,35 +51,12 @@
<item>
<key> <string>_body</string> </key>
<value> <string>computer = state_change[\'object\']\n
computer.edit(allocation_scope=\'open/personal\')\n
portal = computer.getPortalObject()\n
\n
internal_packing_list_url = context.portal_workflow.getInfoFor(\n
ob=computer, name=\'internal_packing_list_url\', \n
wf_id=\'computer_slap_interface_workflow\')\n
\n
internal_packing_list = portal.restrictedTraverse(internal_packing_list_url)\n
\n
# portal.portal_workflow.doActionFor(internal_packing_list, \'deliver_action\')\n
internal_packing_list.deliver()\n
portal.portal_workflow.doActionFor(computer, \'validate_action\')\n
\n
# Create a sale packing to restrict the computer usage by default to only its administrator\n
trade_condition_portal_type = "Sale Trade Condition"\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
sale_trade_condition_module = portal.getDefaultModule(trade_condition_portal_type)\n
sale_trade_condition = sale_trade_condition_module.newContent(\n
portal_type=trade_condition_portal_type,\n
destination_section_value=person,\n
source_section_value=person,\n
title="%s (%s) supply condition" % (computer.getTitle(), computer.getReference()),\n
computer.edit(\n
allocation_scope=\'open/personal\',\n
source_administration_value=person,\n
)\n
sale_trade_condition.newContent(\n
portal_type="Sale Supply Line",\n
aggregate_value=computer,\n
resource=portal.portal_preferences.getPreferredInstanceSetupResource(),\n
)\n
sale_trade_condition.validate()\n
</string> </value>
</item>
<item>
......
<?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>_body</string> </key>
<value> <string>computer = state_change[\'object\']\n
portal = computer.getPortalObject()\n
\n
# reference = computer.getReference("")\n
# if not reference:\n
# computer.edit(reference=portal.portal_ids.generateNewId(\n
# id_group=\'slap_computer_reference\',\n
# id_generator=\'mysql_non_continuous_increasing\'))\n
\n
# Access internal packing list module\n
internal_packing_list_id = portal.getDefaultModuleId(portal_type=\'Internal Packing List\')\n
internal_packing_list_module = portal.restrictedTraverse(internal_packing_list_id)\n
# Create the IPL\n
internal_packing_list = internal_packing_list_module.newContent(\n
portal_type=\'Internal Packing List\',\n
)\n
# User has to access his person profile\n
person_value = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
# Edit IPL data\n
internal_packing_list.edit(\n
start_date=DateTime(),\n
source_administration_value=person_value,\n
destination_value=person_value,\n
destination_section_value=person_value,\n
)\n
\n
# Access service\n
service_module_id = portal.getDefaultModuleId(portal_type=\'Service\')\n
service_module = portal.restrictedTraverse(service_module_id)\n
service_value = service_module.restrictedTraverse(\'computer_registration\')\n
# Edit line\n
internal_packing_list_line = internal_packing_list.newContent(\n
portal_type=\'Internal Packing List Line\',\n
resource_value=service_value,\n
quantity=1,\n
aggregate_value=computer,\n
)\n
\n
# Deliver IPL\n
internal_packing_list.portal_workflow.doActionFor(internal_packing_list, \'confirm_action\')\n
internal_packing_list.portal_workflow.doActionFor(internal_packing_list, \'stop_action\')\n
\n
internal_packing_list.startBuilding()\n
\n
computer.createComputerRegistration(internal_packing_list_url=internal_packing_list.getRelativeUrl())\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_requestRegistration</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -23,7 +23,6 @@
<value>
<tuple>
<string>approve_computer_registration</string>
<string>create_computer_registration</string>
<string>generate_certificate</string>
<string>report_computer_bang</string>
<string>request_computer_registration</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>create_computer_registration</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>var_exprs</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>internal_packing_list_url</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python:state_change.kwargs.get(\'internal_packing_list_url\', \'\')</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -24,7 +24,7 @@
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>Computer_requestRegistration</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="VariableDefinition" module="Products.DCWorkflow.Variables"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_expr</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_value</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>for_status</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>internal_packing_list_url</string> </value>
</item>
<item>
<key> <string>info_guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>update_always</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
849
\ No newline at end of file
850
\ 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