From 13b40bff2c0ddaa1db343d37f345035bdb9cb845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sun, 14 Mar 2021 15:40:57 +0000 Subject: [PATCH] [FIX] base: allow using another postgres schema than public Before 1721ec1363 and fdc4ef97c9d09, Odoo did work fine when the user had another default schema than 'public'. This commit restores this behaviour by searching for existing objects in the user's current schema, which is the first in the schema search path and the one used when no schema is specified when creating objects. closes odoo/odoo#68144 X-original-commit: 223781b34afacd1c0c5674d395cece6d472b048c Signed-off-by: Olivier Dony (odo) --- odoo/tools/sql.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odoo/tools/sql.py b/odoo/tools/sql.py index fc3d6f5524e..7445396856b 100644 --- a/odoo/tools/sql.py +++ b/odoo/tools/sql.py @@ -24,7 +24,7 @@ def existing_tables(cr, tablenames): JOIN pg_namespace n ON (n.oid = c.relnamespace) WHERE c.relname IN %s AND c.relkind IN ('r', 'v', 'm') - AND n.nspname = 'public' + AND n.nspname = current_schema """ cr.execute(query, [tuple(tablenames)]) return [row[0] for row in cr.fetchall()] @@ -43,7 +43,7 @@ def table_kind(cr, tablename): FROM pg_class c JOIN pg_namespace n ON (n.oid = c.relnamespace) WHERE c.relname = %s - AND n.nspname = 'public' + AND n.nspname = current_schema """ cr.execute(query, (tablename,)) return cr.fetchone()[0] if cr.rowcount else None