[IMP] edi: use context manager for new cursor
bzr revid: rco@openerp.com-20140409134440-ylhri8kl6mwv4g2k
This commit is contained in:
parent
89f5844b2a
commit
cde05592ce
|
@ -34,18 +34,14 @@ def _edi_dispatch(db_name, method_name, *method_args):
|
||||||
try:
|
try:
|
||||||
registry = openerp.modules.registry.RegistryManager.get(db_name)
|
registry = openerp.modules.registry.RegistryManager.get(db_name)
|
||||||
assert registry, 'Unknown database %s' % db_name
|
assert registry, 'Unknown database %s' % db_name
|
||||||
edi = registry['edi.edi']
|
with registry.cursor() as cr:
|
||||||
cr = registry.cursor()
|
edi = registry['edi.edi']
|
||||||
res = None
|
return getattr(edi, method_name)(cr, *method_args)
|
||||||
res = getattr(edi, method_name)(cr, *method_args)
|
|
||||||
cr.commit()
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
_logger.exception('Failed to execute EDI method %s with args %r.',
|
_logger.exception('Failed to execute EDI method %s with args %r.',
|
||||||
method_name, method_args)
|
method_name, method_args)
|
||||||
raise
|
raise
|
||||||
finally:
|
|
||||||
cr.close()
|
|
||||||
return res
|
|
||||||
|
|
||||||
def exp_import_edi_document(db_name, uid, passwd, edi_document, context=None):
|
def exp_import_edi_document(db_name, uid, passwd, edi_document, context=None):
|
||||||
return _edi_dispatch(db_name, 'import_edi', uid, edi_document, None)
|
return _edi_dispatch(db_name, 'import_edi', uid, edi_document, None)
|
||||||
|
|
Loading…
Reference in New Issue