Commit df4cfe75 authored by Gabriel Monnerat's avatar Gabriel Monnerat

refactor code to don't call getPortalObject 3 times

parent 27f77511
...@@ -74,17 +74,18 @@ else:\n ...@@ -74,17 +74,18 @@ else:\n
computer_partition.markFree()\n computer_partition.markFree()\n
\n \n
# Deliver all SPL related to this software instance\n # Deliver all SPL related to this software instance\n
isTransitionPossible = context.portal_workflow.isTransitionPossible\n
software_instance = current_delivery_line.getAggregateValue(portal_type="Software Instance")\n software_instance = current_delivery_line.getAggregateValue(portal_type="Software Instance")\n
for sale_packing_list_line in portal.portal_catalog(\n for sale_packing_list_line in portal.portal_catalog(\n
portal_type="Sale Packing List Line", \n portal_type="Sale Packing List Line", \n
default_aggregate_uid=software_instance.getUid(),\n default_aggregate_uid=software_instance.getUid(),\n
simulation_state=NegatedQuery(Query(simulation_state="delivered")),):\n simulation_state=NegatedQuery(Query(simulation_state="delivered")),):\n
sale_packing_list = sale_packing_list_line.getParentValue()\n sale_packing_list = sale_packing_list_line.getParentValue()\n
if sale_packing_list.getPortalObject().portal_workflow.isTransitionPossible(sale_packing_list, \'start\'):\n if isTransitionPossible(sale_packing_list, \'start\'):\n
sale_packing_list.start()\n sale_packing_list.start()\n
if sale_packing_list.getPortalObject().portal_workflow.isTransitionPossible(sale_packing_list, \'stop\'):\n if isTransitionPossible(sale_packing_list, \'stop\'):\n
sale_packing_list.stop()\n sale_packing_list.stop()\n
if sale_packing_list.getPortalObject().portal_workflow.isTransitionPossible(sale_packing_list, \'deliver\'):\n if isTransitionPossible(sale_packing_list, \'deliver\'):\n
sale_packing_list.deliver()\n sale_packing_list.deliver()\n
if sale_packing_list.getSimulationState() != \'delivered\':\n if sale_packing_list.getSimulationState() != \'delivered\':\n
raise ValueError(\'It was not possible to deliver %r during destruction of %r\' % (sale_packing_list.getRelativeUrl(), software_instance.getRelativeUrl()))\n raise ValueError(\'It was not possible to deliver %r during destruction of %r\' % (sale_packing_list.getRelativeUrl(), software_instance.getRelativeUrl()))\n
......
406 407
\ 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