Commit a9f243e7 authored by Jérome Perrin's avatar Jérome Perrin

Remove split & defer transition

We must now be using solvers.
parent 1886b351
<?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># By default, \'Split and Defer\' is possible for all portal types \\\n
# that uses delivery_causality_workflow.\n
return True\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Delivery_isSplitAndDeferPossible</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>delivery = state_change[\'object\']\n
\n
stop_date = state_change.kwargs[\'stop_date\']\n
start_date = state_change.kwargs[\'start_date\']\n
\n
tag = delivery.getPath() + \'_split\'\n
split_and_defer = 0\n
listbox = state_change[\'kwargs\'].get(\'listbox\')\n
split_movement_list = []\n
if listbox is not None:\n
for line in listbox:\n
url = line[\'listbox_key\']\n
choice = line[\'choice\']\n
if choice == \'SplitAndDefer\':\n
split_movement_list.append(delivery.restrictedTraverse(url))\n
\n
delivery.splitAndDefer(split_movement_list=split_movement_list,\n
start_date=start_date,\n
stop_date=stop_date,\n
comment=\'\')\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>Delivery_callSplitAndDeferTransition</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>delivery = state_change[\'object\']\n
\n
split_movement_list = state_change[\'kwargs\'][\'split_movement_list\']\n
start_date = state_change[\'kwargs\'][\'start_date\']\n
stop_date = state_change[\'kwargs\'][\'stop_date\']\n
\n
if not len(split_movement_list):\n
delivery.updateCausalityState()\n
return\n
\n
tag = delivery.getPath() + \'_split\'\n
\n
for movement in split_movement_list:\n
delivery.getPortalObject().portal_simulation.solveMovement(\n
movement, None, \'SplitAndDefer\', start_date=start_date,\n
stop_date=stop_date, activate_kw={\'tag\':tag})\n
\n
delivery.activate(after_tag=tag).updateCausalityState()\n
\n
# Create delivery\n
explanation_uid_list = []\n
object = delivery\n
while object is not None:\n
explanation_uid_list.append(object.getUid())\n
object = object.getCausalityValue()\n
\n
previous_tag = None\n
for delivery_builder in delivery.getBuilderList():\n
this_builder_tag = \'%s_split_%s\' % (delivery.getPath(),\n
delivery_builder.getId())\n
after_tag = [tag]\n
if previous_tag:\n
after_tag.append(previous_tag)\n
delivery_builder.activate(activity=\'SQLQueue\',\n
tag=this_builder_tag,\n
after_tag=after_tag).build(\n
explanation_uid=explanation_uid_list)\n
previous_tag = this_builder_tag\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>Delivery_splitAndDefer</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -34,8 +34,6 @@
<string>solve_automatically</string>
<string>solve_divergence</string>
<string>solve_divergence_action</string>
<string>split_and_defer</string>
<string>split_and_defer_action</string>
<string>start_building</string>
</tuple>
</value>
......
<?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_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>Delivery_splitAndDefer</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>split_and_defer</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string>solving</string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Split and Defer</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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_name</string> </key>
<value> <string>Split and Defer</string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string>%(content_url)s/Delivery_viewSplitAndDeferDialog?field_my_workflow_action=split_and_defer_action</string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>Delivery_callSplitAndDeferTransition</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Keep the current Packing List and create a new one with the difference between prevision and current</string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>split_and_defer_action</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>Split and Defer Action</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Guard" module="Products.DCWorkflow.Guard"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>expr</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>roles</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
</tuple>
</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:here.getSimulationState() not in here.getPortalDraftOrderStateList() and here.Delivery_isSplitAndDeferPossible()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>from Products.CMFCore.utils import getToolByName\n
return getToolByName(context, \'portal_simulation\').solveMovement(context, delivery_solver, target_solver)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>delivery_solver=None, target_solver=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Movement_solveMovement</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
1170
\ No newline at end of file
1171
\ No newline at end of file
......@@ -370,82 +370,6 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin,
if kw:
super(Delivery, self).updateSimulation(**kw)
def splitAndDeferMovementList(self, start_date=None, stop_date=None,
movement_uid_list=[], delivery_solver=None,
target_solver='CopyToTarget', delivery_builder=None):
"""
this method will unlink and delete movements in movement_uid_list and
rebuild a new Packing List with them.
1/ change date in simulation, call TargetSolver and expand
2/ detach simulation movements from to-be-deleted movements
3/ delete movements
XXX make sure that all detached movements are deleted at the same
time, else the interaction workflow would reattach them to a delivery
rule.
4/ call builder
"""
tag_list = []
movement_list = [x for x in self.getMovementList() if x.getUid() in
movement_uid_list]
if not movement_list: return
deferred_simulation_movement_list = []
# defer simulation movements
if start_date is not None or stop_date is not None:
for movement in movement_list:
start_date = start_date or movement.getStartDate()
stop_date = stop_date or movement.getStopDate()
for s_m in movement.getDeliveryRelatedValueList():
if s_m.getStartDate() != start_date or \
s_m.getStopDate() != stop_date:
s_m.edit(start_date=start_date, stop_date=stop_date)
deferred_simulation_movement_list.append(s_m)
solver_tag = '%s_splitAndDefer_solver' % self.getRelativeUrl()
expand_tag = '%s_splitAndDefer_expand' % self.getRelativeUrl()
detach_tag = '%s_splitAndDefer_detach' % self.getRelativeUrl()
build_tag = '%s_splitAndDefer_build' % self.getRelativeUrl()
# call solver and expand on deferrd movements
for movement in movement_list:
movement.activate(tag=solver_tag).Movement_solveMovement(
delivery_solver, target_solver)
tag_list.append(solver_tag)
kw = {'after_tag': tag_list[:], 'tag': expand_tag}
for s_m in deferred_simulation_movement_list:
s_m.expand('deferred', activate_kw=kw)
tag_list.append(expand_tag)
detached_movement_url_list = []
deleted_movement_uid_list = []
#detach simulation movements
for movement in movement_list:
movement_url = movement.getRelativeUrl()
movement_uid = getattr(movement,'uid',None)
if movement_uid: deleted_movement_uid_list.append(movement_uid)
for s_m in movement.getDeliveryRelatedValueList():
delivery_list = \
[x for x in s_m.getDeliveryList() if x != movement_url]
s_m.activate(after_tag=tag_list[:], tag=detach_tag).setDeliveryList(
delivery_list)
detached_movement_url_list.append(s_m.getRelativeUrl())
tag_list.append(detach_tag)
#delete delivery movements
# deleteContent uses the uid as a activity tag
self.activate(after_tag=tag_list[:]).deleteContent([movement.getId() for
movement in movement_list])
tag_list.extend(deleted_movement_uid_list)
# update causality state on self, after deletion
self.activate(after_tag=tag_list[:],
activity='SQLQueue').updateCausalityState()
# call builder on detached movements
builder = getattr(self.portal_deliveries, delivery_builder)
builder.activate(after_tag=tag_list[:], tag=build_tag).build(
movement_relative_url_list=detached_movement_url_list)
#######################################################
# Defer indexing process
def reindexObject(self, *k, **kw):
......
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