Commit 93e5f537 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Prevent 'draft' Solver Process from being created when there is already a 'solving' one (#KH-1107).

  1. 'Solve Divergences' action:
     => Display Delivery_viewSolveDivergenceDialog.listbox:
        -> Delivery_getSolverDecisionList
           -> Delivery_getSolverProcess => create Solver Process in 'draft' state and build Solver Decisions
  2. Clicking 'Update' button updates Solver Decisions.
  3. Click 'Solve Divergences' button after either 'Adopt Prevision' or 'Accept Decision'.
     => SolverProcess.solve():
        Solver Process transit to 'solving' state and 'solve' Activity is created.

Before this Activity is executed, user can still select 'Solve Divergences'
action and this will create another 'Solver Process' as the current one is not
in 'draft' state anymore. Moreover, another user can still 'Adopt Prevision'
(while the first user selected 'Accept Decision') and this will be actually be
applied despite the first user choice.

Instead, create Solver Process when transiting to 'diverged' state and do not
display 'Solve Divergences' button nor allow access to 'Solve Divergences
Dialog' (Delivery_viewSolveDivergenceDialog) if there is a Solver Process in
'solving' state.
parent 73b747dd
<?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>if context.Delivery_getSolverProcess() is None:\n
message = context.Base_translateString("Workflow state may have been updated by other user. Please try again.")\n
return context.Base_redirect(\'view\',\n
keep_items={\'portal_status_message\': message})\n
\n
return context.Delivery_viewSolveDivergenceDialog(*args, **kw)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>*args, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Delivery_solveDivergenceAction</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
draft_solver_process = None\n
for solver_process in delivery.getSolverValueList():\n
validation_state = solver_process.getValidationState()\n
if validation_state == \'solving\':\n
# Currently solving Divergences through solve() Activity\n
return\n
elif solver_process.getValidationState() == \'draft\':\n
draft_solver_process = solver_process\n
\n
if draft_solver_process is not None:\n
draft_solver_process.buildSolverDecisionList(delivery)\n
else:\n
delivery.getPortalObject().portal_solver_processes.newSolverProcess(delivery)\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_diverge</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -20,7 +20,7 @@
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string></string> </value>
<value> <string>Delivery_diverge</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......
......@@ -16,7 +16,7 @@
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string>%(content_url)s/Delivery_viewSolveDivergenceDialog?field_your_workflow_action=solve_divergence_action</string> </value>
<value> <string>%(content_url)s/Delivery_solveDivergenceAction?field_your_workflow_action=solve_divergence_action</string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
......@@ -88,7 +88,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: here.getSimulationState() not in here.getPortalDraftOrderStateList()</string> </value>
<value> <string>python: here.getSimulationState() not in here.getPortalDraftOrderStateList() and here.Delivery_getSolverProcess() is not None</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -50,17 +50,9 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># XXX currently we create a Solver Process and build Solver Decision in it if missing.\n
# But for better performance, Solver Process and Solver Decision should be created beforehand\n
# by causality workflow when a delivery becomes divergent.\n
for solver_process in context.getSolverValueList():\n
<value> <string>for solver_process in context.getSolverValueList():\n
if solver_process.getValidationState() == \'draft\':\n
solver_process.buildSolverDecisionList(context)\n
break\n
else:\n
solver_process = context.getPortalObject().portal_solver_processes.newSolverProcess(context)\n
\n
return solver_process\n
return solver_process\n
</string> </value>
</item>
<item>
......
......@@ -51,7 +51,11 @@
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
\n
solver_process = context.getSolverValueList()[-1]\n
if solver_process.getValidationState() == \'solving\':\n
return\n
\n
solver_decision_uid = int(solver_decision_uid)\n
solver_decision = None\n
for solver_decision in solver_process.objectValues(portal_type="Solver Decision"):\n
......
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