[FIX] fields: convert_to_read, handle missing many2one foreign keys
authorDenis Ledoux <dle@odoo.com>
Tue, 16 Sep 2014 10:28:32 +0000 (12:28 +0200)
committerDenis Ledoux <dle@odoo.com>
Tue, 16 Sep 2014 10:29:37 +0000 (12:29 +0200)
openerp/fields.py

index 2234528..0104302 100644 (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