From dec9a0ba944a1d32f3c0cb70525c4c4d1d0f94a1 Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Wed, 30 Jun 2010 13:05:57 +0000
Subject: [PATCH] In buildSolverDecisionList, if we have only one available
 automatic solver, we just use it automatically.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36740 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/SolverProcess.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/product/ERP5/Document/SolverProcess.py b/product/ERP5/Document/SolverProcess.py
index a18c02d93b..d52ef01ad3 100644
--- a/product/ERP5/Document/SolverProcess.py
+++ b/product/ERP5/Document/SolverProcess.py
@@ -259,6 +259,16 @@ class SolverProcess(XMLObject, ActiveProcess):
           new_decision = self.newContent(portal_type='Solver Decision')
         new_decision._setDeliveryValueList(movement_dict.keys())
         new_decision._setCausality(solver_decision_key[0])
+        # If we have only one available automatic solver, we just use it
+        # automatically.
+        automatic_solver_list = filter(lambda x:x.isAutomaticSolver(),
+                                       solver_list)
+        if len(automatic_solver_list) == 1:
+          automatic_solver = automatic_solver_list[0]
+          new_decision.setSolverValue(automatic_solver)
+          new_decision.updateConfiguration(
+            **automatic_solver.getDefaultConfigurationPropertyDict(
+            new_decision))
         # XXX We need a relation between Simulation Movement and Solver
         # Process, but ideally, the relation should be created when a
         # Target Solver processes, not when a Solver Decision is
-- 
GitLab