diff options
| author | Denis Ledoux <dle@odoo.com> | 2019-10-17 12:29:44 +0000 |
|---|---|---|
| committer | fw-bot <otis@odoo.com> | 2019-10-17 19:20:39 +0000 |
| commit | 0a2fcfbce900e78bcee2d6047d5ec5aa793cdf46 (patch) | |
| tree | 979e29f36195d6b471800ca4bad9c866863cfac1 /odoo/fields.py | |
| parent | 7ee342ee0e8e0e82a200f8428095fef2835eefd7 (diff) | |
[FIX] fields: do not attempt to set foreign keys on views
Users sometimes define custom models on SQL views
e.g. @nseinlet
In such a case, Odoo should not attempt to create foreign keys
as it just cannot work on views.
This could prevent the migration of a database
with such a custom model using a view
when it attempted to fix the missing foreign keys
when updating the modules.
closes odoo/odoo#38988
X-original-commit: dfaea03de57394a9a188f499da664c57dd9adc29
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
Diffstat (limited to 'odoo/fields.py')
| -rw-r--r-- | odoo/fields.py | 3 |
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 |
