Commit 5f38667c authored by Łukasz Nowak's avatar Łukasz Nowak

Create proper Packing List during requesting.

As Hosting Subscription is common document for all Software Instances used in
request process, use it to find common parameters of all deliveries.
parent 300b75a5
<?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>software_instance = state_change[\'object\']\n
hosting_subscription_uid = state_change.kwargs[\'hosting_subscription_uid\']\n
hosting_subscription = software_instance.portal_catalog.getResultValue(uid=hosting_subscription_uid)\n
portal = software_instance.getPortalObject()\n
\n
# Get services\n
portal_preferences = portal.portal_preferences\n
service_uid_list = []\n
\n
if service_relative_url is None:\n
for service_relative_url in \\\n
(portal_preferences.getPreferredInstanceSetupResource(),\n
portal_preferences.getPreferredInstanceHostingResource(),\n
portal_preferences.getPreferredInstanceCleanupResource(),\n
):\n
service = portal.restrictedTraverse(service_relative_url)\n
service_uid_list.append(service.getUid())\n
else:\n
service = portal.restrictedTraverse(service_relative_url)\n
service_uid_list.append(service.getUid())\n
\n
# Packing List valid state\n
state_list = []\n
state_list.extend(portal.getPortalReservedInventoryStateList())\n
state_list.extend(portal.getPortalTransitInventoryStateList())\n
state_list.extend(portal.getPortalCurrentInventoryStateList())\n
\n
packing_list_line = portal.portal_catalog.getResultValue(\n
portal_type=\'Sale Packing List Line\',\n
simulation_state=state_list,\n
aggregate_uid=hosting_subscription_uid,\n
default_resource_uid=service_uid_list,\n
sort_on=((\'movement.start_date\', \'DESC\'),),\n
limit=1,\n
)\n
\n
if packing_list_line is None:\n
raise ValueError("No sale packing list line found for %s" % \\\n
hosting_subscription.getRelativeUrl())\n
else:\n
return packing_list_line\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change, service_relative_url=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>HostingSubscription_getInstancePackingListLine</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -146,11 +146,22 @@ software_release_document = context.portal_catalog.getResultValue(\n ...@@ -146,11 +146,22 @@ software_release_document = context.portal_catalog.getResultValue(\n
# protect computer partition from being selected again\n # protect computer partition from being selected again\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
\n \n
hosting_subscription = software_instance.portal_catalog.getResultValue(uid=hosting_subscription_uid)\n
sale_packing_list_line = context.HostingSubscription_getInstancePackingListLine(state_change)\n
base_sale_packing_list = sale_packing_list_line.getParentValue()\n
# XXX: SoftwareInstance_createSalePackingList shall be used to create new Sale Packing List\n # XXX: SoftwareInstance_createSalePackingList shall be used to create new Sale Packing List\n
sale_packing_list_module = portal.getDefaultModule(portal_type=\'Sale Packing List\')\n sale_packing_list_module = portal.getDefaultModule(portal_type=\'Sale Packing List\')\n
sale_packing_list = sale_packing_list_module.newContent(portal_type=\'Sale Packing List\', \n \n
start_date=DateTime())\n sale_packing_list = sale_packing_list_module.newContent(\n
hosting_subscription = software_instance.portal_catalog.getResultValue(uid=hosting_subscription_uid)\n portal_type=\'Sale Packing List\', \n
start_date=DateTime(),\n
specialise=base_sale_packing_list.getSpecialise() or base_sale_packing_list.getCausalityValue().getSpecialise(),\n
destination=base_sale_packing_list.getDestination(),\n
destination_section=base_sale_packing_list.getDestinationSection(),\n
destination_decision=base_sale_packing_list.getDestinationDecision(),\n
source=base_sale_packing_list.getSource(),\n
source_section=base_sale_packing_list.getSourceSection(),\n
price_currency=base_sale_packing_list.getPriceCurrency())\n
sale_packing_list_line = sale_packing_list.newContent(\n sale_packing_list_line = sale_packing_list.newContent(\n
portal_type=\'Sale Packing List Line\',\n portal_type=\'Sale Packing List Line\',\n
resource=context.portal_preferences.getPreferredInstanceSetupResource(),\n resource=context.portal_preferences.getPreferredInstanceSetupResource(),\n
......
228 229
\ No newline at end of file \ 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