Launchpad automatic translations update.
[odoo/odoo.git] / bin / workflow / workitem.py
index fe098bd..bd98e8f 100644 (file)
@@ -1,21 +1,20 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
 ##############################################################################
 #
-#    OpenERP, Open Source Management Solution  
-#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
-#    $Id$
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
@@ -88,10 +87,11 @@ def _execute(cr, workitem, activity, ident, stack):
     #
     # send a signal to parent workflow (signal: subflow.signal_name)
     #
+    signal_todo = []
     if (workitem['state']=='active') and activity['signal_send']:
-        cr.execute("select i.id,w.osv,i.res_id from wkf_instance i left join wkf w on (i.wkf_id=w.id) where i.id in (select inst_id from wkf_workitem where subflow_id=%s)", (workitem['inst_id'],))
+        cr.execute("select i.id,w.osv,i.res_id from wkf_instance i left join wkf w on (i.wkf_id=w.id) where i.id IN (select inst_id from wkf_workitem where subflow_id=%s)", (workitem['inst_id'],))
         for i in cr.fetchall():
-            instance.validate(cr, i[0], (ident[0],i[1],i[2]), activity['signal_send'], force_running=True)
+            signal_todo.append((i[0], (ident[0],i[1],i[2]), activity['signal_send']))
 
     if activity['kind']=='dummy':
         if workitem['state']=='active':
@@ -139,6 +139,9 @@ def _execute(cr, workitem, activity, ident, stack):
             state= cr.fetchone()[0]
             if state=='complete':
                 _state_set(cr, workitem, activity, 'complete', ident)
+    for t in signal_todo:
+        instance.validate(cr, t[0], t[1], t[2], force_running=True)
+
     return result
 
 def _split_test(cr, workitem, split_mode, ident, signal=None, stack=None):