From 05cbf2acbf7f5e50153489b99535f814791505cd Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 18 Jul 2011 19:29:43 +0200 Subject: [FIX] modules.loading: no warning about access right for osv inheriting from osv_memory bzr revid: odo@openerp.com-20110718172943-jyfew63ruy9npqk5 --- openerp/modules/loading.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'openerp/modules/loading.py') diff --git a/openerp/modules/loading.py b/openerp/modules/loading.py index 6bb45e77598..0afa0c1769e 100644 --- a/openerp/modules/loading.py +++ b/openerp/modules/loading.py @@ -359,7 +359,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): cr.execute("""select distinct mod.model, mod.name from ir_model_access acc, ir_model mod where acc.model_id = mod.id""") for (model, name) in cr.fetchall(): model_obj = pool.get(model) - if isinstance(model_obj, osv.osv.osv_memory): + if isinstance(model_obj, osv.osv.osv_memory) and not isinstance(model_obj, osv.osv.osv): logger.notifyChannel('init', netsvc.LOG_WARNING, 'In-memory object %s (%s) should not have explicit access rules!' % (model, name)) cr.execute("SELECT model from ir_model") -- cgit v1.2.3 From 51117db34435806a4443aa05ff6d17a2e48fe1ba Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 16 Aug 2011 11:57:55 +0200 Subject: [REF] osv: replace isinstance(m,osv_memory) by m.is_transient(). bzr revid: vmt@openerp.com-20110816095755-2g5cblolcvchtewx --- openerp/modules/loading.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'openerp/modules/loading.py') diff --git a/openerp/modules/loading.py b/openerp/modules/loading.py index 45a466e5462..85d86e8d7e1 100644 --- a/openerp/modules/loading.py +++ b/openerp/modules/loading.py @@ -339,16 +339,16 @@ def load_modules(db, force_demo=False, status=None, update_module=False): cr.execute("""select model,name from ir_model where id NOT IN (select distinct model_id from ir_model_access)""") for (model, name) in cr.fetchall(): model_obj = pool.get(model) - if model_obj and not isinstance(model_obj, osv.osv.osv_memory): - logger.notifyChannel('init', netsvc.LOG_WARNING, 'object %s (%s) has no access rules!' % (model, name)) + if model_obj and not model_obj.is_transient(): + logger.notifyChannel('init', netsvc.LOG_WARNING, 'The model %s (%s) has no access rules!' % (model, name)) # Temporary warning while we remove access rights on osv_memory objects, as they have # been replaced by owner-only access rights cr.execute("""select distinct mod.model, mod.name from ir_model_access acc, ir_model mod where acc.model_id = mod.id""") for (model, name) in cr.fetchall(): model_obj = pool.get(model) - if isinstance(model_obj, osv.osv.osv_memory): - logger.notifyChannel('init', netsvc.LOG_WARNING, 'In-memory object %s (%s) should not have explicit access rules!' % (model, name)) + if model_obj.is_transient(): + logger.notifyChannel('init', netsvc.LOG_WARNING, 'The transient model %s (%s) should not have explicit access rules!' % (model, name)) cr.execute("SELECT model from ir_model") for (model,) in cr.fetchall(): -- cgit v1.2.3 From 79d0e39c4c0924dbee8ddc884752fc73c3812fe5 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Fri, 2 Sep 2011 15:27:12 +0200 Subject: [FIX] loading: load base only once. bzr revid: vmt@openerp.com-20110902132712-j9bgfnzbmddarr7h --- openerp/modules/loading.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'openerp/modules/loading.py') diff --git a/openerp/modules/loading.py b/openerp/modules/loading.py index 45a466e5462..4bc8e440b62 100644 --- a/openerp/modules/loading.py +++ b/openerp/modules/loading.py @@ -158,7 +158,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules= logger.info('module %s: loading objects', package.name) migrations.migrate_module(package, 'pre') register_module_classes(package.name) - models = pool.instanciate(package.name, cr) + models = pool.load(cr, package) loaded_modules.append(package.name) if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'): init_module_models(cr, package.name, models) @@ -273,8 +273,6 @@ def load_modules(db, force_demo=False, status=None, update_module=False): # This is a brand new pool, just created in pooler.get_db_and_pool() pool = pooler.get_pool(cr.dbname) - processed_modules = [] # for cleanup step after install - loaded_modules = [] # to avoid double loading report = tools.assertion_report() if 'base' in tools.config['update'] or 'all' in tools.config['update']: cr.execute("update ir_module_module set state=%s where name=%s and state=%s", ('to upgrade', 'base', 'installed')) @@ -285,8 +283,10 @@ def load_modules(db, force_demo=False, status=None, update_module=False): if not graph: logger.notifyChannel('init', netsvc.LOG_CRITICAL, 'module base cannot be loaded! (hint: verify addons-path)') raise osv.osv.except_osv(_('Could not load base module'), _('module base cannot be loaded! (hint: verify addons-path)')) - loaded, processed = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report) - processed_modules.extend(processed) + + # processed_modules: for cleanup step after install + # loaded_modules: to avoid double loading + loaded_modules, processed_modules = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report) if tools.config['load_language']: for lang in tools.config['load_language'].split(','): -- cgit v1.2.3 From 2e7a1342283e2db729cae0556dc4763a53d6926d Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 23 Sep 2011 14:45:25 +0200 Subject: [IMP] orm: introduce cleaner class hierarchy for models We'll now have a BaseModel with 3 subclasses, AbstractModel, TransientModel and Model. Model is for regular models, TransientModel for automatically-vacuumed models, and AbstractModel for common superclasses meant to be inherited by other models only, and not directly used. bzr revid: odo@openerp.com-20110923124525-jfzk55dk3ban2ps2 --- openerp/modules/loading.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'openerp/modules/loading.py') diff --git a/openerp/modules/loading.py b/openerp/modules/loading.py index 24b23720119..1bdbbe3d0be 100644 --- a/openerp/modules/loading.py +++ b/openerp/modules/loading.py @@ -340,7 +340,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): for (model, name) in cr.fetchall(): model_obj = pool.get(model) if model_obj and not model_obj.is_transient(): - logger.notifyChannel('init', netsvc.LOG_WARNING, 'The model %s (%s) has no access rules!' % (model, name)) + logger.notifyChannel('init', netsvc.LOG_WARNING, 'Model %s (%s) has no access rules!' % (model, name)) # Temporary warning while we remove access rights on osv_memory objects, as they have # been replaced by owner-only access rights @@ -348,7 +348,9 @@ def load_modules(db, force_demo=False, status=None, update_module=False): for (model, name) in cr.fetchall(): model_obj = pool.get(model) if model_obj.is_transient(): - logger.notifyChannel('init', netsvc.LOG_WARNING, 'The transient model (formerly osv_memory) %s (%s) should not have explicit access rules!' % (model, name)) + import pdb + pdb.set_trace() + logger.notifyChannel('init', netsvc.LOG_WARNING, 'The transient model %s (%s) should not have explicit access rules!' % (model, name)) cr.execute("SELECT model from ir_model") for (model,) in cr.fetchall(): @@ -356,7 +358,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): if obj: obj._check_removed_columns(cr, log=True) else: - logger.notifyChannel('init', netsvc.LOG_WARNING, "Model %s is referenced but not present in the orm pool!" % model) + logger.notifyChannel('init', netsvc.LOG_WARNING, "Model %s is declared but cannot be loaded! (Perhaps a module was partially removed or renamed)" % model) # Cleanup orphan records pool.get('ir.model.data')._process_end(cr, 1, processed_modules) -- cgit v1.2.3 From 2fbd4dfcdf98583611853346f03b9a6dc5febd52 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 23 Sep 2011 15:44:13 +0200 Subject: [FIX] loading: remove leftover debugging breakpoint bzr revid: odo@openerp.com-20110923134413-d71l4y5265z3nwcb --- openerp/modules/loading.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'openerp/modules/loading.py') diff --git a/openerp/modules/loading.py b/openerp/modules/loading.py index 1bdbbe3d0be..9f6c517dca7 100644 --- a/openerp/modules/loading.py +++ b/openerp/modules/loading.py @@ -348,8 +348,6 @@ def load_modules(db, force_demo=False, status=None, update_module=False): for (model, name) in cr.fetchall(): model_obj = pool.get(model) if model_obj.is_transient(): - import pdb - pdb.set_trace() logger.notifyChannel('init', netsvc.LOG_WARNING, 'The transient model %s (%s) should not have explicit access rules!' % (model, name)) cr.execute("SELECT model from ir_model") -- cgit v1.2.3