Raise error on read of a browse object with bad id
Check if id is valid by searching record columns when a key error is raised If the record has the column, the key error is actually an error on a missing or inaccessible id. Signed-off-by: Sandy Carter <sandy.carter@savoirfairelinux.com> Closes #3658
This commit is contained in:
parent
6629729f2d
commit
aa10972d13
|
@ -501,7 +501,17 @@ class browse_record(object):
|
|||
def __getattr__(self, name):
|
||||
try:
|
||||
return self[name]
|
||||
except KeyError, e:
|
||||
except KeyError as e:
|
||||
if name in self._all_columns:
|
||||
raise ValueError(
|
||||
'Cannot fetch field "%(field)s" for "%(model)s" record '
|
||||
'with ID %(id)s, that record does not exist or has been '
|
||||
'deleted' % {
|
||||
'field': name,
|
||||
'model': self._model._name,
|
||||
'id': self._id,
|
||||
}
|
||||
)
|
||||
raise AttributeError(e)
|
||||
|
||||
def __contains__(self, name):
|
||||
|
|
Loading…
Reference in New Issue