Commit 57145fd9 by Sebastien Robin

simulation: improve change "If divergence is solved by other user, then show a nice message."

Do not handle solving issues in Workflow_statusModify, use directly script attached to the
dialog of solving divergence. Also, previous code was no longer working properly with latest
simulation
1 parent 972f705f
......@@ -64,8 +64,18 @@ if not listbox:\n
item[\'listbox_key\'] = key\n
repaired_listbox.append(item)\n
listbox = repaired_listbox\n
\n
\n
line_list = context.Delivery_getSolverDecisionList(listbox=listbox)\n
\n
def displayParallelChangeMessage():\n
message = translateString("Workflow state may have been updated by other user. Please try again.")\n
return context.Base_redirect(form_id, keep_items={\'portal_status_message\': message}, **kw)\n
\n
# if we are not divergence any more\n
if len(line_list) == 0:\n
return displayParallelChangeMessage()\n
\n
line = None\n
for listbox_dict in listbox:\n
listbox_key = listbox_dict[\'listbox_key\']\n
line = [x for x in line_list if x.getPath() == listbox_key][0]\n
......@@ -80,6 +90,10 @@ for listbox_dict in listbox:\n
else:\n
line.setProperty(property, value)\n
\n
# if divergence solving is already ongoing and will be fixed by activities\n
if line is None:\n
return displayParallelChangeMessage()\n
\n
solver_process = line.getParentValue()\n
solver_process.buildTargetSolverList()\n
solver_process.solve()\n
......
......@@ -51,8 +51,15 @@
<item>
<key> <string>_body</string> </key>
<value> <string>request= context.REQUEST\n
from Products.ERP5Type.Message import translateString\n
\n
listbox = request.get(\'listbox\')\n
line_list = context.Delivery_getSolverDecisionList(listbox=listbox)\n
\n
if len(line_list) == 0:\n
message = translateString("Workflow state may have been updated by other user. Please try again.")\n
return context.Base_redirect(form_id, keep_items={\'portal_status_message\': message}, **kw)\n
\n
for listbox_key in listbox:\n
listbox_dict = listbox[listbox_key]\n
line = [x for x in line_list if x.getPath() == listbox_key][0]\n
......@@ -72,7 +79,7 @@ return context.Delivery_viewSolveDivergenceDialog(listbox=listbox)\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>listbox=[],**kw</string> </value>
<value> <string>form_id=\'view\', listbox=[],**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -74,13 +74,8 @@ try:\n
except FormValidationError, validation_errors:\n
# Pack errors into the request\n
field_errors = form.ErrorFields(validation_errors)\n
# Only for solve divergence dialog.\n
if dialog_id == \'Delivery_viewSolveDivergenceDialog\' and set([error.error_key for error in field_errors.values()])==set([\'unknown_selection\']):\n
message = translateString("Workflow state may have been updated by other user. Please try again.")\n
return context.Base_redirect(form_id, keep_items={\'portal_status_message\': message}, **kw)\n
else:\n
request.set(\'field_errors\', field_errors)\n
return form(request)\n
request.set(\'field_errors\', field_errors)\n
return form(request)\n
\n
# XXX: this is a duplication from form validation code in Base_callDialogMethod\n
# Correct fix is to factorise this script with Base_callDialogMethod, not to\n
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!