[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
This commit is contained in:
Jay (Open ERP)
2009-06-26 19:57:34 +05:30
parent a393946dec
commit e6f4c4fb2b
+15 -3
View File
@@ -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