summaryrefslogtreecommitdiff
path: root/odoo/modules/registry.py
diff options
context:
space:
mode:
authorwan <wan@odoo.com>2020-08-12 15:29:15 +0000
committerRaphael Collet <rco@odoo.com>2020-08-20 07:45:18 +0000
commitf2ceef0e2f0efb2e47b5f595a80009184305a2c4 (patch)
treefc890511b910167a2ecec0881ddd7169007cbe10 /odoo/modules/registry.py
parent9ad16bf84a0a1e33426105ec20670042e00f19b9 (diff)
[IMP] core: add models defined by a query instead of a table/view
By adding a parameter `_table_query` on the Model, we can now have views that depend on the context. The query is used instead of the table name in ORM operations. This allows to pre-compute some values to improve performance, instead of storing context values in the database. Co-authored-by: william-andre <wan@odoo.com> Co-authored-by: rco-odoo <rco@odoo.com>
Diffstat (limited to 'odoo/modules/registry.py')
-rw-r--r--odoo/modules/registry.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py
index 1126b05e82a..8ccb1615113 100644
--- a/odoo/modules/registry.py
+++ b/odoo/modules/registry.py
@@ -491,7 +491,11 @@ class Registry(Mapping):
Verify that all tables are present and try to initialize those that are missing.
"""
env = odoo.api.Environment(cr, SUPERUSER_ID, {})
- table2model = {model._table: name for name, model in env.items() if not model._abstract}
+ table2model = {
+ model._table: name
+ for name, model in env.items()
+ if not model._abstract and model.__class__._table_query is None
+ }
missing_tables = set(table2model).difference(existing_tables(cr, table2model))
if missing_tables: