[FIX]procurement:added a new cursor for new thread
authorMayur Maheshwari (OpenERP) <mma@tinyerp.com>
Tue, 20 Dec 2011 09:38:20 +0000 (15:08 +0530)
committerMayur Maheshwari (OpenERP) <mma@tinyerp.com>
Tue, 20 Dec 2011 09:38:20 +0000 (15:08 +0530)
lp bug: https://launchpad.net/bugs/906727 fixed

bzr revid: mma@tinyerp.com-20111220093820-bh4bgg9n7g9jtl1e

addons/procurement/wizard/orderpoint_procurement.py

index 8f9c1fc..89c08bd 100644 (file)
@@ -25,6 +25,7 @@
 #
 
 import threading
+import pooler
 from osv import fields,osv
 
 class procurement_compute(osv.osv_memory):
@@ -48,9 +49,12 @@ class procurement_compute(osv.osv_memory):
         @param context: A standard dictionary
         """
         proc_obj = self.pool.get('procurement.order')
-        for proc in self.browse(cr, uid, ids, context=context):
-            proc_obj._procure_orderpoint_confirm(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname, context=context)
-
+        #As this function is in a new thread, I need to open a new cursor, because the old one may be closed
+        new_cr = pooler.get_db(cr.dbname).cursor()
+        for proc in self.browse(new_cr, uid, ids, context=context):
+            proc_obj._procure_orderpoint_confirm(new_cr, uid, automatic=proc.automatic, use_new_cursor=new_cr.dbname, context=context)
+        #close the new cursor
+        new_cr.close()
         return {}
 
     def procure_calculation(self, cr, uid, ids, context=None):