def preload_registries(dbnames):
 config = odoo.tools.config
 test_file = config['test_file']
 dbnames = (dbnames or [])
 rc = 0
 for dbname in dbnames:
  try:
   update_module = (config['init'] or config['update'])
   registry = Registry.new(dbname, update_module=update_module)
   if test_file:
    _logger.info('loading test file %s', test_file)
    with odoo.api.Environment.manage():
     if test_file.endswith('yml'):
      load_test_file_yml(registry, test_file)
     elif test_file.endswith('py'):
      load_test_file_py(registry, test_file)
   if registry._assertion_report.failures:
    rc += 1
  except Exception:
   _logger.critical('Failed to initialize database `%s`.', dbname, exc_info=True)
   return (-1)
 return rc

def preload_registries ( dbnames ) : config = odoo . tools . config test_file = config [ 'test_file' ] dbnames = ( dbnames or [ ] ) rc = 0 for dbname in dbnames : try : update_module = ( config [ 'init' ] or config [ 'update' ] ) registry = Registry . new ( dbname , update_module = update_module ) if test_file : _logger . info ( 'loading test file %s' , test_file ) with odoo . api . Environment . manage ( ) : if test_file . endswith ( 'yml' ) : load_test_file_yml ( registry , test_file ) elif test_file . endswith ( 'py' ) : load_test_file_py ( registry , test_file ) if registry . _assertion_report . failures : rc += 1 except Exception : _logger . critical ( 'Failed to initialize database `%s`.' , dbname , exc_info = True ) return ( - 1 ) return rc
preload a registries .