[FIX] openerp.modules.loading: previous change disabled demo data altogether,

this should be now fixed by making sure that --withou-demo flag (or its absence)
is taken care of, and setting the base module demo field.
Normally the demo state of a module should have a ripple
effect on all modules depending on it. This might prove
not enough in this case and require some more testing.

bzr revid: vmt@openerp.com-20111117162824-yqswv6yk7bmiyj4s
This commit is contained in:
Vo Minh Thu 2011-11-17 17:28:24 +01:00
parent e2d8f8b1df
commit e9c405c244
3 changed files with 14 additions and 8 deletions

View File

@ -90,7 +90,8 @@ def preload_registry(dbname):
""" Preload a registry, and start the cron."""
try:
update_module = True if config['init'] or config['update'] else False
db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=update_module, pooljobs=False)
db, registry = openerp.pooler.get_db_and_pool(
dbname, update_module=update_module, pooljobs=False, force_demo=not config['without_demo'])
# jobs will start to be processed later, when openerp.cron.start_master_thread() is called by openerp.service.start_services()
registry.schedule_cron_jobs()
@ -101,7 +102,8 @@ def run_test_file(dbname, test_file):
""" Preload a registry, possibly run a test file, and start the cron."""
try:
update_module = True if config['init'] or config['update'] else False
db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=update_module, pooljobs=False)
db, registry = openerp.pooler.get_db_and_pool(
dbname, update_module=update_module, pooljobs=False, force_demo=not config['without_demo'])
cr = db.cursor()
logger = logging.getLogger('server')
logger.info('loading test file %s', test_file)

View File

@ -88,15 +88,19 @@ class Graph(dict):
for k, v in additional_data[package.name].items():
setattr(package, k, v)
def add_module(self, cr, module, force=None):
self.add_modules(cr, [module], force)
def add_module(self, cr, module, force_demo=False):
self.add_modules(cr, [module], force_demo)
def add_modules(self, cr, module_list, force=None):
if force is None:
force = []
def add_modules(self, cr, module_list, force_demo=False):
packages = []
len_graph = len(self)
for module in module_list:
if force_demo:
cr.execute("""
UPDATE ir_module_module
SET demo='t'
WHERE name = %s""",
(module,))
# This will raise an exception if no/unreadable descriptor file.
# NOTE The call to load_information_from_description_file is already
# done by db.initialize, so it is possible to not do it again here.

View File

@ -281,7 +281,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
# STEP 1: LOAD BASE (must be done before module dependencies can be computed for later steps)
graph = openerp.modules.graph.Graph()
graph.add_module(cr, 'base', force)
graph.add_module(cr, 'base', force_demo)
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)'))