From b1dfb8e1936d26e0776e59dfab4383457ba19939 Mon Sep 17 00:00:00 2001 From: kevin wang Date: Sat, 17 May 2014 22:55:51 +0800 Subject: [PATCH] check no match result in convert_pgerror_* functions --- openerp/osv/orm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index a198e013746..9b63e8efc15 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -5217,7 +5217,7 @@ def convert_pgerror_23502(model, fields, info, e): m = re.match(r'^null value in column "(?P\w+)" violates ' r'not-null constraint\n', str(e)) - field_name = m.group('field') + field_name = m and m.group('field') if not m or field_name not in fields: return {'message': unicode(e)} message = _(u"Missing required value for the field '%s'.") % field_name @@ -5232,7 +5232,7 @@ def convert_pgerror_23502(model, fields, info, e): def convert_pgerror_23505(model, fields, info, e): m = re.match(r'^duplicate key (?P\w+) violates unique constraint', str(e)) - field_name = m.group('field') + field_name = m and m.group('field') if not m or field_name not in fields: return {'message': unicode(e)} message = _(u"The value for the field '%s' already exists.") % field_name