diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 7f064a401a8..f0cec27b2cd 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -5469,10 +5469,10 @@ class ImportWarning(Warning): 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)) + tools.ustr(e)) field_name = m.group('field') if not m or field_name not in fields: - return {'message': unicode(e)} + return {'message': tools.ustr(e)} message = _(u"Missing required value for the field '%s'.") % field_name field = fields.get(field_name) if field: @@ -5484,10 +5484,10 @@ 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)) + tools.ustr(e)) field_name = m.group('field') if not m or field_name not in fields: - return {'message': unicode(e)} + return {'message': tools.ustr(e)} message = _(u"The value for the field '%s' already exists.") % field_name field = fields.get(field_name) if field: @@ -5500,7 +5500,7 @@ def convert_pgerror_23505(model, fields, info, e): PGERROR_TO_OE = collections.defaultdict( # shape of mapped converters - lambda: (lambda model, fvg, info, pgerror: {'message': unicode(pgerror)}), { + lambda: (lambda model, fvg, info, pgerror: {'message': tools.ustr(pgerror)}), { # not_null_violation '23502': convert_pgerror_23502, # unique constraint error