From e6f4c4fb2b2f868f757719077690cf3bf15a343b Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Fri, 26 Jun 2009 19:57:34 +0530 Subject: [PATCH] [FIX] SQL Constraint failure error on particular record while importing lp bug: https://launchpad.net/bugs/355493 fixed bzr revid: jvo@tinyerp.com-20090626142734-6xy0e1z4d1o75soo --- bin/osv/orm.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index cedacb728b3..4d91e4a213f 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -653,9 +653,21 @@ class orm_template(object): if warning: cr.rollback() return (-1, res, warning, '') - id = self.pool.get('ir.model.data')._update(cr, uid, self._name, - current_module, res, xml_id=data_id, mode=mode, - noupdate=noupdate) + + try: + id = self.pool.get('ir.model.data')._update(cr, uid, self._name, + current_module, res, xml_id=data_id, mode=mode, + noupdate=noupdate) + except Exception, e: + import psycopg2 + if isinstance(e,psycopg2.IntegrityError): + msg= 'Insertion Failed!' + for key in self.pool._sql_error.keys(): + if key in e[0]: + msg = self.pool._sql_error[key] + break + return (-1, res,msg,'' ) + for lang in translate: context2 = context.copy() context2['lang'] = lang