From 0a2aa97be7948da62c451c3e58c50842f5b2dab9 Mon Sep 17 00:00:00 2001 From: Kazuhiko Shiozaki <kazuhiko@nexedi.com> Date: Fri, 25 Jun 2010 13:09:38 +0000 Subject: [PATCH] commit the initial proof of concept of automatic divergence solving interaction workflow. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36601 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../workflow_chain_type.xml | 24 +++ .../divergence_interaction_workflow.xml | 49 ++++++ .../interactions.xml | 31 ++++ .../solve_divergence_automatically.xml | 93 ++++++++++ .../scripts.xml | 31 ++++ .../Workflow_solveDivergenceAutomatically.xml | 165 ++++++++++++++++++ .../variables.xml | 25 +++ .../worklists.xml | 25 +++ bt5/erp5_simulation/bt/revision | 2 +- .../template_portal_type_workflow_chain_list | 6 + .../bt/template_workflow_id_list | 1 + 11 files changed, 451 insertions(+), 1 deletion(-) create mode 100644 bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow.xml create mode 100644 bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/interactions.xml create mode 100644 bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/interactions/solve_divergence_automatically.xml create mode 100644 bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/scripts.xml create mode 100644 bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/scripts/Workflow_solveDivergenceAutomatically.xml create mode 100644 bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/variables.xml create mode 100644 bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/worklists.xml diff --git a/bt5/erp5_simulation/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml b/bt5/erp5_simulation/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml index f05c89edf1..971ffd8b92 100644 --- a/bt5/erp5_simulation/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml +++ b/bt5/erp5_simulation/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml @@ -27,6 +27,18 @@ <type>Production Reduction Solver</type> <workflow>solver_workflow</workflow> </chain> + <chain> + <type>Purchase Invoice Transaction</type> + <workflow>divergence_interaction_workflow</workflow> + </chain> + <chain> + <type>Purchase Order</type> + <workflow>divergence_interaction_workflow</workflow> + </chain> + <chain> + <type>Purchase Packing List</type> + <workflow>divergence_interaction_workflow</workflow> + </chain> <chain> <type>Quantity Cancel Solver</type> <workflow>solver_workflow</workflow> @@ -35,6 +47,18 @@ <type>Quantity Split Solver</type> <workflow>solver_workflow</workflow> </chain> + <chain> + <type>Sale Invoice Transaction</type> + <workflow>divergence_interaction_workflow</workflow> + </chain> + <chain> + <type>Sale Order</type> + <workflow>divergence_interaction_workflow</workflow> + </chain> + <chain> + <type>Sale Packing List</type> + <workflow>divergence_interaction_workflow</workflow> + </chain> <chain> <type>Solver Process</type> <workflow>solver_process_workflow</workflow> diff --git a/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow.xml b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow.xml new file mode 100644 index 0000000000..f2ac62e232 --- /dev/null +++ b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow.xml @@ -0,0 +1,49 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="InteractionWorkflowDefinition" module="Products.ERP5.InteractionWorkflow"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_objects</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>creation_guard</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> <string>This workflow tries to solve divergences automatically.</string> </value> + </item> + <item> + <key> <string>groups</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>divergence_interaction_workflow</string> </value> + </item> + <item> + <key> <string>manager_bypass</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>Divergence Interaction Workflow</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/interactions.xml b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/interactions.xml new file mode 100644 index 0000000000..6788072919 --- /dev/null +++ b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/interactions.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="Interaction" module="Products.ERP5.Interaction"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_mapping</string> </key> + <value> + <dictionary/> + </value> + </item> + <item> + <key> <string>_objects</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>interactions</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/interactions/solve_divergence_automatically.xml b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/interactions/solve_divergence_automatically.xml new file mode 100644 index 0000000000..ac554ff078 --- /dev/null +++ b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/interactions/solve_divergence_automatically.xml @@ -0,0 +1,93 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="InteractionDefinition" module="Products.ERP5.Interaction"/> + <tuple/> + </tuple> + </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>activate_script_name</string> </key> + <value> + <list> + <string>Workflow_solveDivergenceAutomatically</string> + </list> + </value> + </item> + <item> + <key> <string>after_script_name</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>before_commit_script_name</string> </key> + <value> + <tuple/> + </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>solve_divergence_automatically</string> </value> + </item> + <item> + <key> <string>method_id</string> </key> + <value> + <list> + <string>diverge</string> + </list> + </value> + </item> + <item> + <key> <string>once_per_transaction</string> </key> + <value> <int>1</int> </value> + </item> + <item> + <key> <string>portal_type_filter</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>script_name</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>trigger_type</string> </key> + <value> <int>2</int> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/scripts.xml b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/scripts.xml new file mode 100644 index 0000000000..0622b3c34f --- /dev/null +++ b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/scripts.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="Scripts" module="Products.DCWorkflow.Scripts"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_mapping</string> </key> + <value> + <dictionary/> + </value> + </item> + <item> + <key> <string>_objects</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>scripts</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/scripts/Workflow_solveDivergenceAutomatically.xml b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/scripts/Workflow_solveDivergenceAutomatically.xml new file mode 100644 index 0000000000..86e3453c9b --- /dev/null +++ b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/scripts/Workflow_solveDivergenceAutomatically.xml @@ -0,0 +1,165 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + <tuple/> + </tuple> + </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 +solver_tool = getattr(delivery.getPortalObject(), \'portal_solvers\', None)\n +solver_process_tool = getattr(delivery.getPortalObject(), \'portal_solver_processes\', None)\n +\n +if solver_tool is None or solver_process_tool is None:\n + return\n +\n +for tester, simulation_movement in delivery.getDivergentTesterAndSimulationMovementList():\n + for solver in solver_tool.searchTargetSolverList(tester, simulation_movement, automatic_solver_only=True):\n + if solver.isAutomaticSolver():\n + # XXX We sometimes want to store solver process document persistently.\n + solver_process = solver_process_tool.newContent(\n + portal_type=\'Solver Process\', temp_object=True)\n + # XXX We need to calculate and pass default values for some solvers\n + target_solver = solver_process.newContent(\n + portal_type=solver.getId(),\n + delivery=simulation_movement.getDeliveryList()\n + )\n + target_solver.startSolving()\n + target_solver.solve()\n + break\n +</string> </value> + </item> + <item> + <key> <string>_code</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>state_change, **kw</string> </value> + </item> + <item> + <key> <string>_proxy_roles</string> </key> + <value> + <tuple> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>errors</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>func_code</string> </key> + <value> + <object> + <klass> + <global name="FuncCode" module="Shared.DC.Scripts.Signature"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>co_argcount</string> </key> + <value> <int>1</int> </value> + </item> + <item> + <key> <string>co_varnames</string> </key> + <value> + <tuple> + <string>state_change</string> + <string>kw</string> + <string>_getitem_</string> + <string>delivery</string> + <string>getattr</string> + <string>_getattr_</string> + <string>None</string> + <string>solver_tool</string> + <string>solver_process_tool</string> + <string>_getiter_</string> + <string>tester</string> + <string>simulation_movement</string> + <string>True</string> + <string>solver</string> + <string>solver_process</string> + <string>target_solver</string> + </tuple> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>func_defaults</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Workflow_solveDivergenceAutomatically</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/variables.xml b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/variables.xml new file mode 100644 index 0000000000..5547232278 --- /dev/null +++ b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/variables.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="Variables" module="Products.DCWorkflow.Variables"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_mapping</string> </key> + <value> + <dictionary/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>variables</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/worklists.xml b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/worklists.xml new file mode 100644 index 0000000000..1f8b17b012 --- /dev/null +++ b/bt5/erp5_simulation/WorkflowTemplateItem/portal_workflow/divergence_interaction_workflow/worklists.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="Worklists" module="Products.DCWorkflow.Worklists"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_mapping</string> </key> + <value> + <dictionary/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>worklists</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_simulation/bt/revision b/bt5/erp5_simulation/bt/revision index 2702ba3d43..d2c5ed2124 100644 --- a/bt5/erp5_simulation/bt/revision +++ b/bt5/erp5_simulation/bt/revision @@ -1 +1 @@ -115 \ No newline at end of file +116 \ No newline at end of file diff --git a/bt5/erp5_simulation/bt/template_portal_type_workflow_chain_list b/bt5/erp5_simulation/bt/template_portal_type_workflow_chain_list index 2582a97604..b70a9e5749 100644 --- a/bt5/erp5_simulation/bt/template_portal_type_workflow_chain_list +++ b/bt5/erp5_simulation/bt/template_portal_type_workflow_chain_list @@ -5,8 +5,14 @@ DateTime Divergence Tester | edit_workflow Float Divergence Tester | edit_workflow Net Converted Quantity Divergence Tester | edit_workflow Production Reduction Solver | solver_workflow +Purchase Invoice Transaction | divergence_interaction_workflow +Purchase Order | divergence_interaction_workflow +Purchase Packing List | divergence_interaction_workflow Quantity Cancel Solver | solver_workflow Quantity Split Solver | solver_workflow +Sale Invoice Transaction | divergence_interaction_workflow +Sale Order | divergence_interaction_workflow +Sale Packing List | divergence_interaction_workflow Solver Process | solver_process_workflow String Divergence Tester | edit_workflow Trade Model Solver | solver_workflow diff --git a/bt5/erp5_simulation/bt/template_workflow_id_list b/bt5/erp5_simulation/bt/template_workflow_id_list index 71d1ab261e..a197806f18 100644 --- a/bt5/erp5_simulation/bt/template_workflow_id_list +++ b/bt5/erp5_simulation/bt/template_workflow_id_list @@ -1,2 +1,3 @@ +divergence_interaction_workflow solver_process_workflow solver_workflow \ No newline at end of file -- 2.30.9