From 9411a2da03ebfe9d1aeacc43c8bd789a64f647e9 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 1 Aug 2014 22:42:01 +0200 Subject: [PATCH] [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 --- openerp/osv/orm.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index f0c8337ea6d..00093999bca 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -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