[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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user