[FIX] module loading: mark module as initialized *after* the data files have been loaded
When the registry is updating, the view verification only validates the views from initialized modules. Not taking the current module allow update of views that have also an inherited view in the same module. The verification of the base view must not try to apply the old inherited view against it as it may not be applicable anymore. After module update, we re-validate all the views of this module. This is needed because a module can declare two (or more) inherited views that are correct when applyed alone, but not when combined with others. bzr revid: chs@openerp.com-20140418141550-7b57b1xl4fx0rgqq
This commit is contained in:
parent
04c993bddf
commit
c3cf8000e6
|
@ -955,4 +955,18 @@ class view(osv.osv):
|
|||
ids = map(itemgetter(0), cr.fetchall())
|
||||
return self._check_xml(cr, uid, ids)
|
||||
|
||||
def _validate_module_views(self, cr, uid, module):
|
||||
"""Validate architecture of all the views of a given module"""
|
||||
assert not self.pool._init or module in self.pool._init_modules
|
||||
cr.execute("""SELECT max(v.id)
|
||||
FROM ir_ui_view v
|
||||
LEFT JOIN ir_model_data md ON (md.model = 'ir.ui.view' AND md.res_id = v.id)
|
||||
WHERE md.module = %s
|
||||
GROUP BY coalesce(v.inherit_id, v.id)
|
||||
""", (module,))
|
||||
|
||||
for vid, in cr.fetchall():
|
||||
if not self._check_xml(cr, uid, [vid]):
|
||||
self.raise_view_error(cr, uid, "Can't validate view", vid)
|
||||
|
||||
# vim:et:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
# Copyright (C) 2010-2013 OpenERP s.a. (<http://openerp.com>).
|
||||
# Copyright (C) 2010-2014 OpenERP s.a. (<http://openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
|
@ -153,7 +153,6 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules=
|
|||
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)
|
||||
registry._init_modules.add(package.name)
|
||||
status['progress'] = float(index) / len(graph)
|
||||
|
||||
# Can't put this line out of the loop: ir.module.module will be
|
||||
|
@ -182,6 +181,10 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules=
|
|||
|
||||
migrations.migrate_module(package, 'post')
|
||||
|
||||
registry._init_modules.add(package.name)
|
||||
# validate all the views at a whole
|
||||
registry['ir.ui.view']._validate_module_views(cr, SUPERUSER_ID, module_name)
|
||||
|
||||
if has_demo:
|
||||
# launch tests only in demo mode, allowing tests to use demo data.
|
||||
if tools.config.options['test_enable']:
|
||||
|
@ -207,6 +210,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules=
|
|||
if hasattr(package, kind):
|
||||
delattr(package, kind)
|
||||
|
||||
registry._init_modules.add(package.name)
|
||||
cr.commit()
|
||||
|
||||
# The query won't be valid for models created later (i.e. custom model
|
||||
|
|
Loading…
Reference in New Issue