Commit 31017e41 authored by Łukasz Nowak's avatar Łukasz Nowak

Implement generic script to request SR changes.

parent bdf5b458
<?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 encoding="cdata"><![CDATA[
computer = state_change[\'object\']\n
# Get required arguments\n
kwargs = state_change.kwargs\n
software_release_url = state_change.kwargs["software_release_url"]\n
\n
portal = computer.getPortalObject()\n
\n
# Only get one software release\n
software_release_document_result = portal.portal_catalog(\n
portal_type=\'Software Release\', # validation_state=(\'shared\', \'released\', \'published\', \'shared_alive\', \'released_alive\', \'published_alive\'),\n
url_string=software_release_url, limit=2)\n
if len(software_release_document_result) != 1:\n
raise ValueError("No software release found for %s %s" % (computer.getRelativeUrl(), software_release_url))\n
else:\n
software_release_document = software_release_document_result[0]\n
\n
if len(context.Computer_getSoftwarePackingListLineList(state_change, service_uid_list=[service_uid])) > 0:\n
# change installation in progress\n
return\n
\n
# XXX Hardcoded values\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
\n
packing_list_portal_type = "Purchase Packing List"\n
module = portal.getDefaultModule(portal_type=packing_list_portal_type)\n
packing_list = module.newContent(\n
portal_type=packing_list_portal_type,\n
start_date=DateTime(),\n
destination_value=person,\n
destination_section_value=person,\n
destination_decision_value=person,\n
source_administration_value=person,\n
# XXX Hardcoded values\n
source="organisation_module/vifib_internet",\n
source_section="organisation_module/vifib_internet",\n
price_currency="currency_module/EUR",\n
)\n
packing_list.newContent(\n
portal_type="Purchase Packing List Line",\n
resource_uid=service_uid,\n
aggregate_value_list=[software_release_document, computer],\n
quantity=1\n
)\n
\n
portal.portal_workflow.doActionFor(packing_list, "confirm_action")\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change, service_uid</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_requestSoftwareReleaseChange</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -51,51 +51,13 @@
<item>
<key> <string>_body</string> </key>
<value> <string>computer = state_change[\'object\']\n
# Get required arguments\n
kwargs = state_change.kwargs\n
software_release_url = state_change.kwargs["software_release_url"]\n
\n
portal = computer.getPortalObject()\n
\n
# Only get one software release\n
software_release_document_result = portal.portal_catalog(\n
portal_type=\'Software Release\', # validation_state=(\'shared\', \'released\', \'published\', \'shared_alive\', \'released_alive\', \'published_alive\'),\n
url_string=software_release_url, limit=2)\n
if len(software_release_document_result) != 1:\n
raise ValueError("No software release found for %s %s" % (computer.getRelativeUrl(), software_release_url))\n
else:\n
software_release_document = software_release_document_result[0]\n
\n
# Software installation service\n
service_relative_url = portal.portal_preferences.\\\n
getPreferredSoftwareSetupResource()\n
service = portal.restrictedTraverse(service_relative_url)\n
\n
# XXX Hardcoded values\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
\n
packing_list_portal_type = "Purchase Packing List"\n
module = portal.getDefaultModule(portal_type=packing_list_portal_type)\n
packing_list = module.newContent(\n
portal_type=packing_list_portal_type,\n
start_date=DateTime(),\n
destination_value=person,\n
destination_section_value=person,\n
destination_decision_value=person,\n
source_administration_value=person,\n
# XXX Hardcoded values\n
source="organisation_module/vifib_internet",\n
source_section="organisation_module/vifib_internet",\n
price_currency="currency_module/EUR",\n
)\n
packing_list.newContent(\n
portal_type="Purchase Packing List Line",\n
resource_value=service,\n
aggregate_value_list=[software_release_document, computer],\n
quantity=1\n
)\n
\n
portal.portal_workflow.doActionFor(packing_list, "confirm_action")\n
context.Computer_requestSoftwareReleaseChange(state_change, service_uid=service.getUid())\n
</string> </value>
</item>
<item>
......
678
\ No newline at end of file
679
\ 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