[FIX] Model.load(): extra error checking while importing data
If any missing or partially incorrect values cause an exception other than a psycopg2 error, we should still catch it, rollback that record and report the error, rather than letting bubble and fail without any feedback to the user. Fixes #1485
This commit is contained in:
parent
19e401adf0
commit
9411a2da03
|
@ -1389,6 +1389,16 @@ class BaseModel(object):
|
|||
# Failed to write, log to messages, rollback savepoint (to
|
||||
# avoid broken transaction) and keep going
|
||||
cr.execute('ROLLBACK TO SAVEPOINT model_load_save')
|
||||
except Exception, e:
|
||||
message = (_('Unknown error during import:') +
|
||||
u' %s: %s' % (type(e), unicode(e)))
|
||||
moreinfo = _('Resolve other errors first')
|
||||
messages.append(dict(info, type='error',
|
||||
message=message,
|
||||
moreinfo=moreinfo))
|
||||
# Failed for some reason, perhaps due to invalid data supplied,
|
||||
# rollback savepoint and keep going
|
||||
cr.execute('ROLLBACK TO SAVEPOINT model_load_save')
|
||||
if any(message['type'] == 'error' for message in messages):
|
||||
cr.execute('ROLLBACK TO SAVEPOINT model_load')
|
||||
ids = False
|
||||
|
|
Loading…
Reference in New Issue