[IMP] better logging during import failure

bzr revid: xmo@openerp.com-20121105100717-pqexs7j710s2ea2i
This commit is contained in:
Xavier Morel 2012-11-05 11:07:17 +01:00
parent c1d04e00d6
commit f02c4266d6
1 changed files with 2 additions and 0 deletions

View File

@ -1352,9 +1352,11 @@ class BaseModel(object):
noupdate=noupdate, res_id=id, context=context))
cr.execute('RELEASE SAVEPOINT model_load_save')
except psycopg2.Warning, e:
_logger.exception('Failed to import record %s', record)
cr.execute('ROLLBACK TO SAVEPOINT model_load_save')
messages.append(dict(info, type='warning', message=str(e)))
except psycopg2.Error, e:
_logger.exception('Failed to import record %s', record)
# Failed to write, log to messages, rollback savepoint (to
# avoid broken transaction) and keep going
cr.execute('ROLLBACK TO SAVEPOINT model_load_save')