[FIX] setup Environment for the report thread
This commit is contained in:
parent
4acee39f80
commit
8083afe7c3
|
@ -87,25 +87,26 @@ def exp_report(db, uid, object, ids, datas=None, context=None):
|
||||||
self_reports[id] = {'uid': uid, 'result': False, 'state': False, 'exception': None}
|
self_reports[id] = {'uid': uid, 'result': False, 'state': False, 'exception': None}
|
||||||
|
|
||||||
def go(id, uid, ids, datas, context):
|
def go(id, uid, ids, datas, context):
|
||||||
cr = openerp.registry(db).cursor()
|
with openerp.api.Environment.manage():
|
||||||
try:
|
cr = openerp.registry(db).cursor()
|
||||||
result, format = openerp.report.render_report(cr, uid, ids, object, datas, context)
|
try:
|
||||||
if not result:
|
result, format = openerp.report.render_report(cr, uid, ids, object, datas, context)
|
||||||
tb = sys.exc_info()
|
if not result:
|
||||||
self_reports[id]['exception'] = openerp.exceptions.DeferredException('RML is not available at specified location or not enough data to print!', tb)
|
tb = sys.exc_info()
|
||||||
self_reports[id]['result'] = result
|
self_reports[id]['exception'] = openerp.exceptions.DeferredException('RML is not available at specified location or not enough data to print!', tb)
|
||||||
self_reports[id]['format'] = format
|
self_reports[id]['result'] = result
|
||||||
self_reports[id]['state'] = True
|
self_reports[id]['format'] = format
|
||||||
except Exception, exception:
|
self_reports[id]['state'] = True
|
||||||
_logger.exception('Exception: %s\n', exception)
|
except Exception, exception:
|
||||||
if hasattr(exception, 'name') and hasattr(exception, 'value'):
|
_logger.exception('Exception: %s\n', exception)
|
||||||
self_reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value))
|
if hasattr(exception, 'name') and hasattr(exception, 'value'):
|
||||||
else:
|
self_reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value))
|
||||||
tb = sys.exc_info()
|
else:
|
||||||
self_reports[id]['exception'] = openerp.exceptions.DeferredException(tools.exception_to_unicode(exception), tb)
|
tb = sys.exc_info()
|
||||||
self_reports[id]['state'] = True
|
self_reports[id]['exception'] = openerp.exceptions.DeferredException(tools.exception_to_unicode(exception), tb)
|
||||||
cr.commit()
|
self_reports[id]['state'] = True
|
||||||
cr.close()
|
cr.commit()
|
||||||
|
cr.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
threading.Thread(target=go, args=(id, uid, ids, datas, context)).start()
|
threading.Thread(target=go, args=(id, uid, ids, datas, context)).start()
|
||||||
|
|
Loading…
Reference in New Issue