[IMP] Do not create FK when destination model is _auto=False
authorSamus CTO <cto@openerp.com>
Tue, 5 Aug 2014 09:34:19 +0000 (11:34 +0200)
committerMartin Trigaux <mat@openerp.com>
Tue, 5 Aug 2014 13:02:23 +0000 (15:02 +0200)
It is not useful to try to create foreign keys when the destination model is
a PostgreSQL view for example.
We already do this kind of verifications but ir.actions and transient models
but did not for _auto.

openerp/models.py

index af55db1..c28a231 100644 (file)
@@ -2621,7 +2621,7 @@ class BaseModel(object):
 
                             if isinstance(f, fields.many2one) or (isinstance(f, fields.function) and f._type == 'many2one' and f.store):
                                 dest_model = self.pool[f._obj]
-                                if dest_model._table != 'ir_actions':
+                                if dest_model._auto and dest_model._table != 'ir_actions':
                                     self._m2o_fix_foreign_key(cr, self._table, k, dest_model, f.ondelete)
 
                     # The field doesn't exist in database. Create it if necessary.