[FIX] fields: convert_to_read, handle missing many2one foreign keys

This commit is contained in:
Denis Ledoux
2014-09-16 12:29:37 +02:00
parent cb55107fe1
commit d6741c8b54
+5 -1
View File
@@ -1368,7 +1368,11 @@ class Many2one(_Relational):
# evaluate name_get() as superuser, because the visibility of a
# many2one field value (id and name) depends on the current record's
# access rights, and not the value's access rights.
return value.sudo().name_get()[0]
try:
return value.sudo().name_get()[0]
except MissingError:
# Should not happen, unless the foreign key is missing.
return False
else:
return value.id