From f2ceef0e2f0efb2e47b5f595a80009184305a2c4 Mon Sep 17 00:00:00 2001 From: wan Date: Wed, 12 Aug 2020 15:29:15 +0000 Subject: [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 Co-authored-by: rco-odoo --- odoo/modules/registry.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'odoo/modules') 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: -- cgit v1.2.3