Commit 22827f97 authored by Romain Courteaud's avatar Romain Courteaud

Update packing list can not be created as a clone if the instance has never been started.

parent 83d0713f
......@@ -64,6 +64,9 @@ if (state in (started, stopped)):\n
delivery = instance.getCausalityValue(portal_type=["Sale Packing List"])\n
update_service_relative_url = portal.portal_preferences.getPreferredInstanceUpdateResource()\n
\n
if delivery is None:\n
new_delivery = context.Instance_createSalePackingList(state_change, portal.restrictedTraverse(update_service_relative_url))\n
else:\n
new_delivery = delivery.Base_createCloneDocument(batch_mode=1)\n
new_delivery.edit(start_date=DateTime(), stop_date=DateTime())\n
new_delivery.contentValues(portal_type="Sale Packing List Line")[0].edit(resource=update_service_relative_url)\n
......
......@@ -141,20 +141,6 @@ else:\n
instance.edit(causality_value=packing_list)\n
else:\n
# Create a new packing list from scratch\n
sale_order_line = delivery.contentValues(portal_type=sale_order_line_portal_type)[0]\n
\n
packing_list_module = portal.getDefaultModule(portal_type=\'Sale Packing List\')\n
packing_list = packing_list_module.newContent(\n
portal_type=\'Sale Packing List\',\n
specialise=delivery.getSpecialise() or delivery.getCausalityValue().getSpecialise(),\n
destination=delivery.getDestination(),\n
destination_section=delivery.getDestinationSection(),\n
destination_decision=delivery.getDestinationDecision(),\n
source=delivery.getSource(),\n
source_section=delivery.getSourceSection(),\n
price_currency=delivery.getPriceCurrency(),\n
start_date=DateTime())\n
\n
if (state == started):\n
service_relative_url = hosting_service_relative_url\n
service = hosting_service\n
......@@ -162,16 +148,7 @@ else:\n
service_relative_url = cleanup_service_relative_url\n
service = cleanup_service\n
\n
packing_list_line = packing_list.newContent(\n
portal_type=\'Sale Packing List Line\',\n
resource=service_relative_url,\n
quantity_unit="unit/piece",\n
quantity=1,\n
aggregate_list=sale_order_line.getAggregateList(),\n
# XXX Hardcode price on service\n
price=service.getSaleSupplyLineBasePrice(),\n
)\n
\n
packing_list = context.Instance_createSalePackingList(state_change, service)\n
instance.edit(causality_value=packing_list)\n
\n
if (state == started):\n
......
<?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>instance = state_change[\'object\']\n
\n
# Get current sale order\n
delivery = instance.getCausalityValue(portal_type=["Sale Order"])\n
\n
sale_order_line = delivery.contentValues(portal_type="Sale Order Line")[0]\n
\n
packing_list_module = portal.getDefaultModule(portal_type=\'Sale Packing List\')\n
packing_list = packing_list_module.newContent(\n
portal_type=\'Sale Packing List\',\n
specialise=delivery.getSpecialise() or delivery.getCausalityValue().getSpecialise(),\n
destination=delivery.getDestination(),\n
destination_section=delivery.getDestinationSection(),\n
destination_decision=delivery.getDestinationDecision(),\n
source=delivery.getSource(),\n
source_section=delivery.getSourceSection(),\n
price_currency=delivery.getPriceCurrency(),\n
start_date=DateTime())\n
\n
packing_list_line = packing_list.newContent(\n
portal_type=\'Sale Packing List Line\',\n
resource=service.getRelativeUrl(),\n
quantity_unit="unit/piece",\n
quantity=1,\n
aggregate_list=sale_order_line.getAggregateList(),\n
# XXX Hardcode price on service\n
price=service.getSaleSupplyLineBasePrice(),\n
)\n
\n
return packing_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change, service</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Instance_createSalePackingList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
16
\ No newline at end of file
17
\ 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