[FIX]procurement:added a new cursor for new thread

lp bug: https://launchpad.net/bugs/906727 fixed

bzr revid: mma@tinyerp.com-20111220093820-bh4bgg9n7g9jtl1e
This commit is contained in:
Mayur Maheshwari (OpenERP) 2011-12-20 15:08:20 +05:30
parent fbca027edc
commit 353b93873e
1 changed files with 7 additions and 3 deletions

View 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):