summaryrefslogtreecommitdiff
path: root/odoo/fields.py
diff options
context:
space:
mode:
Diffstat (limited to 'odoo/fields.py')
-rw-r--r--odoo/fields.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/odoo/fields.py b/odoo/fields.py
index 7662a0b0031..b757beae734 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -2347,6 +2347,9 @@ class Many2one(_Relational):
def update_db_foreign_key(self, model, column):
comodel = model.env[self.comodel_name]
+ # foreign keys do not work on views, and users can define custom models on sql views.
+ if not model._is_an_ordinary_table() or not comodel._is_an_ordinary_table():
+ return
# ir_actions is inherited, so foreign key doesn't work on it
if not comodel._auto or comodel._table == 'ir_actions':
return