From 0e635b66786b8cf2a59f66bc62d8d3347c09f5fa Mon Sep 17 00:00:00 2001 From: archetipo Date: Mon, 12 Sep 2016 14:18:25 +0200 Subject: [PATCH 01/33] fix for odoo 10 --- anybox/recipe/odoo/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anybox/recipe/odoo/server.py b/anybox/recipe/odoo/server.py index c117f7ec..cc110f7d 100644 --- a/anybox/recipe/odoo/server.py +++ b/anybox/recipe/odoo/server.py @@ -102,7 +102,7 @@ def _create_default_config(self): self.options.setdefault('options.admin_passwd', '') sys.path.append(self.openerp_dir) sys.path.extend([egg.location for egg in self.ws]) - from openerp.tools.config import configmanager + from odoo.tools.config import configmanager configmanager(self.config_path).save() def _create_gunicorn_conf(self, qualified_name): From 8f59731ddae68227d881afd15a88efa98fd50aee Mon Sep 17 00:00:00 2001 From: archetipo Date: Mon, 12 Sep 2016 14:26:39 +0200 Subject: [PATCH 02/33] change openerp to odoo [FIX] upgrade.py change openerp to odoo [FIX] change opneerp to odoo in session [FIX] runtime modules [FIX] change registry to env --- README.rst | 1 + anybox/recipe/odoo/runtime/patch_odoo.py | 2 +- anybox/recipe/odoo/runtime/session.py | 65 +++++++++++------------- anybox/recipe/odoo/runtime/upgrade.py | 9 ++-- 4 files changed, 37 insertions(+), 40 deletions(-) diff --git a/README.rst b/README.rst index 85c23513..c5dfce5a 100644 --- a/README.rst +++ b/README.rst @@ -99,3 +99,4 @@ Contributors: * Sandy Carter * Holger Brunn * Leonardo Rochael Almeida + * Alessio Gerace diff --git a/anybox/recipe/odoo/runtime/patch_odoo.py b/anybox/recipe/odoo/runtime/patch_odoo.py index 40fbf810..02dd669f 100644 --- a/anybox/recipe/odoo/runtime/patch_odoo.py +++ b/anybox/recipe/odoo/runtime/patch_odoo.py @@ -12,7 +12,7 @@ def do_patch(gevent_script_path): isolated from the actual process management logic in the original. """ - from openerp.service.server import PreforkServer, stripped_sys_argv + from odoo.service.server import PreforkServer, stripped_sys_argv def long_polling_spawn(server): nargs = stripped_sys_argv() diff --git a/anybox/recipe/odoo/runtime/session.py b/anybox/recipe/odoo/runtime/session.py index 1e92cf6c..82c43e7c 100644 --- a/anybox/recipe/odoo/runtime/session.py +++ b/anybox/recipe/odoo/runtime/session.py @@ -7,18 +7,18 @@ try: - import openerp + import odoo except ImportError: - warnings.warn("This must be imported with a buildout openerp recipe " + warnings.warn("This must be imported with a buildout odoo recipe " "driven sys.path", RuntimeWarning) else: try: - from openerp.cli import server as startup + from odoo.cli import server as startup except ImportError: from .backports.cli import server as startup - from openerp.tools import config - from openerp import SUPERUSER_ID - from openerp.tools.parse_version import parse_version + from odoo.tools import config + from odoo import SUPERUSER_ID + from odoo.tools.parse_version import parse_version from optparse import OptionParser # we support python >= 2.6 @@ -32,7 +32,7 @@ class OpenERPVersion(Version): """Odoo idea of version, wrapped in a class. - This is based on :meth:`openerp.tools.parse_version`, and + This is based on :meth:`odoo.tools.parse_version`, and Provides straight-ahead comparison with tuples of integers, or distutils Version classes. """ @@ -156,15 +156,15 @@ def open(self, db=None, with_demo=False): if not db: db = '' # expected value expected by Odoo to start defaulting. - cnx = openerp.sql_db.db_connect(db) + cnx = odoo.sql_db.db_connect(db) cr = cnx.cursor() - self.is_initialization = not(openerp.modules.db.is_initialized(cr)) + self.is_initialization = not(odoo.modules.db.is_initialized(cr)) cr.close() startup.check_root_user() if not os.environ.get('ENABLE_POSTGRES_USER'): startup.check_postgres_user() - openerp.netsvc.init_logger() + odoo.netsvc.init_logger() saved_without_demo = config['without_demo'] if with_demo is None: @@ -173,15 +173,14 @@ def open(self, db=None, with_demo=False): config['without_demo'] = not with_demo self.with_demo = with_demo - self._registry = openerp.modules.registry.RegistryManager.get( + self._registry = odoo.modules.registry.RegistryManager.get( db, update_module=False) config['without_demo'] = saved_without_demo self.init_cursor() self.uid = SUPERUSER_ID self.init_environments() - self.context = self.registry('res.users').context_get( - self.cr, self.uid) - if hasattr(openerp, 'api'): + self.context = self.env['res.users'].context_get() + if hasattr(odoo, 'api'): self.env.context = self.context def init_environments(self): @@ -202,14 +201,14 @@ def init_environments(self): side effects. This can be done by calling :meth:`clean_environments`. """ try: - gen_factory = openerp.api.Environment.manage + gen_factory = odoo.api.Environment.manage except AttributeError: return self._environments_gen_context = gen_factory().gen self._environments_gen_context.next() - if hasattr(openerp, 'api'): - self.env = openerp.api.Environment( + if hasattr(odoo, 'api'): + self.env = odoo.api.Environment( self.cr, self.uid, getattr( self, 'context', {} ) @@ -285,8 +284,8 @@ def db_version(self): if db_version is not None: return db_version - db_version = self.registry('ir.config_parameter').get_param( - self.cr, self.uid, self._version_parameter_name) + db_version = self.env['ir.config_parameter'].get_param( + self._version_parameter_name) if not db_version: # as usual Odoo thinks its simpler to use False as None # restoring sanity ASAP @@ -298,8 +297,8 @@ def db_version(self): @db_version.setter def db_version(self, version): - self.registry('ir.config_parameter').set_param( - self.cr, self.uid, self._version_parameter_name, str(version)) + self.env['ir.config_parameter'].set_param( + self._version_parameter_name, str(version)) self._db_version = OpenERPVersion(version) @property @@ -330,7 +329,7 @@ def update_modules_list(self): This is necessary prior to install of any new module. """ - self.registry('ir.module.module').update_list(self.cr, self.uid) + self.env['ir.module.module'].update_list() def init_cursor(self): db = getattr(self._registry, 'db', None) @@ -345,7 +344,10 @@ def init_cursor(self): def registry(self, model): """Lookup model by name and return a ready-to-work instance.""" - return self._registry.get(model) + if self.env: + return self.env[model] + else: + return self._registry.get(model) def rollback(self): self.cr.rollback() @@ -377,7 +379,7 @@ def close(self): self.clean_environments() # GR: I did check that implementation is designed not to fail # on Odoo 8 and OpenERP 7 - openerp.modules.registry.RegistryManager.delete(dbname) + odoo.modules.registry.RegistryManager.delete(dbname) def update_modules(self, modules, db=None): """Update the prescribed modules in the database. @@ -403,7 +405,7 @@ def update_modules(self, modules, db=None): self.close() for module in modules: config['update'][module] = 1 - self._registry = openerp.modules.registry.RegistryManager.get( + self._registry = odoo.modules.registry.RegistryManager.get( db, update_module=True) config['update'].clear() self.init_cursor() @@ -454,7 +456,7 @@ def install_modules(self, modules, db=None, update_modules_list=True, config['without_demo'] = not getattr(self, 'with_demo', open_with_demo) for module in modules: config['init'][module] = 1 - self._registry = openerp.modules.registry.RegistryManager.get( + self._registry = odoo.modules.registry.RegistryManager.get( db, update_module=True, force_demo=self.with_demo) config['init'].clear() config['without_demo'] = saved_without_demo @@ -472,12 +474,7 @@ def ref(self, external_id): raise ValueError( "ref requires a fully qualified parameter: 'module.identifier'" ) - ir_model_data = self.registry('ir.model.data') - module, name = external_id.split('.', 1) - _, ref_id = ir_model_data.get_object_reference( - self.cr, self.uid, module, name - ) - return ref_id + return self.env.ref(external_id).id def browse_ref(self, external_id): """Return ir.model.data browse object from its external identifier. @@ -491,9 +488,7 @@ def browse_ref(self, external_id): "browse_ref requires a fully qualified parameter: " "'module.identifier'" ) - ir_model_data = self.registry('ir.model.data') - module, name = external_id.split('.', 1) - return ir_model_data.get_object(self.cr, self.uid, module, name) + return self.env.ref(external_id).browse() def handle_command_line_options(self, to_handle): """Handle prescribed command line options and eat them. diff --git a/anybox/recipe/odoo/runtime/upgrade.py b/anybox/recipe/odoo/runtime/upgrade.py index c379bde1..0f245e3f 100644 --- a/anybox/recipe/odoo/runtime/upgrade.py +++ b/anybox/recipe/odoo/runtime/upgrade.py @@ -81,7 +81,7 @@ def upgrade(upgrade_script, upgrade_callable, conf, buildout_dir): session = Session(conf, buildout_dir) - from openerp.tools import config + from odoo.tools import config config['logfile'] = log_path config['log-level'] = log_level @@ -92,8 +92,9 @@ def upgrade(upgrade_script, upgrade_callable, conf, buildout_dir): log_path, log_level, console_level)) print('') - logger = logging.getLogger('openerp.upgrade') - console_handler = logging.StreamHandler(sys.stdout) + logger = logging.getLogger('odoo.upgrade') + console_handler = logging.StreamHandler() + console_handler.setLevel(getattr(logging, console_level)) console_handler.setFormatter(logging.Formatter( "%(asctime)s %(levelname)s %(message)s")) @@ -141,7 +142,7 @@ def upgrade(upgrade_script, upgrade_callable, conf, buildout_dir): else: logger.info("Database latest upgrade version : %s", db_version) - upgrade_module = imp.load_source('anybox.recipe.odoo.upgrade_openerp', + upgrade_module = imp.load_source('anybox.recipe.odoo.upgrade_odoo', upgrade_script) statuscode = getattr(upgrade_module, upgrade_callable)(session, logger) if statuscode is None or statuscode == 0: From 43495a0bad97338a1e92a913ec6137d95f121235 Mon Sep 17 00:00:00 2001 From: archetipo Date: Tue, 27 Sep 2016 11:43:11 +0200 Subject: [PATCH 03/33] [FIX] path odoo/addons [FIX] change var name openerp_dir -> odoo_dir --- anybox/recipe/odoo/base.py | 54 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/anybox/recipe/odoo/base.py b/anybox/recipe/odoo/base.py index cb75a2e5..e03a665a 100644 --- a/anybox/recipe/odoo/base.py +++ b/anybox/recipe/odoo/base.py @@ -207,11 +207,11 @@ def __init__(self, buildout, name, options): self.options['extra-paths'] = os.linesep.join(self.extra_paths) self.downloads_dir = self.make_absolute( - self.b_options.get('openerp-downloads-directory', 'downloads')) + self.b_options.get('odoo-downloads-directory', 'downloads')) self.version_wanted = None # from the buildout self.version_detected = None # string from the openerp setup.py self.parts = self.buildout['buildout']['parts-directory'] - self.openerp_dir = None + self.odoo_dir = None self.archive_filename = None self.archive_path = None # downloaded tar.gz @@ -275,7 +275,7 @@ def parse_version(self): # in all other cases, the first token is the type of version type_spec = version_split[0] if type_spec in ('local', 'path'): - self.openerp_dir = join(self.buildout_dir, version_split[1]) + self.odoo_dir = join(self.buildout_dir, version_split[1]) self.sources[main_software] = ('local', None) elif type_spec == 'url': url = version_split[1] @@ -305,7 +305,7 @@ def parse_version(self): # VCS types type_spec, url, repo_dir, self.version_wanted = version_split[0:4] options = dict(opt.split('=') for opt in version_split[4:]) - self.openerp_dir = join(self.parts, repo_dir) + self.odoo_dir = join(self.parts, repo_dir) self.sources[main_software] = (type_spec, (url, self.version_wanted), options) @@ -379,7 +379,7 @@ def apply_odoo_requirements_file(self): more complicated. """ req_fname = 'requirements.txt' - req_path = join(self.openerp_dir, req_fname) + req_path = join(self.odoo_dir, req_fname) if not os.path.exists(req_path): logger.warn("%r not found in this version of " "Odoo, although the configuration said to use it. " @@ -614,7 +614,7 @@ def read_release(self): in an old OpenERP version. Could become the norm, but setup is also used to list dependencies. """ - with open(join(self.openerp_dir, 'bin', 'release.py'), 'rb') as f: + with open(join(self.odoo_dir, 'bin', 'release.py'), 'rb') as f: mod = imp.load_module('release', f, 'release.py', ('.py', 'r', imp.PY_SOURCE)) self.version_detected = mod.version @@ -633,7 +633,7 @@ def new_setup(*args, **kw): setuptools.setup = new_setup distutils.core.setup = new_setup sys.path.insert(0, '.') - with open(join(self.openerp_dir, 'setup.py'), 'rb') as f: + with open(join(self.odoo_dir, 'setup.py'), 'rb') as f: saved_argv = sys.argv sys.argv = ['setup.py', 'develop'] try: @@ -912,7 +912,7 @@ def revert_sources(self): continue vcs_type, vcs_spec, options = desc - local_dir = self.openerp_dir if target is main_software else target + local_dir = self.odoo_dir if target is main_software else target local_dir = self.make_absolute(local_dir) repo = vcs.repo(vcs_type, local_dir, vcs_spec[0], **options) try: @@ -1020,7 +1020,7 @@ def retrieve_main_software(self): if type_spec == 'local': logger.info('Local directory chosen, nothing to do') if self.clean: - utils.clean_object_files(self.openerp_dir) + utils.clean_object_files(self.odoo_dir) elif type_spec == 'downloadable': # download if needed if ((self.archive_path and @@ -1037,14 +1037,14 @@ def retrieve_main_software(self): # as openerp-6.1-1 assert(first.isdir()) extracted_name = first.name.split('/')[0] - self.openerp_dir = join(self.parts, extracted_name) + self.odoo_dir = join(self.parts, extracted_name) # protection against malicious tarballs assert(not os.path.isabs(extracted_name)) - assert(self.openerp_dir.startswith(self.parts)) + assert(self.odoo_dir.startswith(self.parts)) - logger.info("Cleaning existing %s", self.openerp_dir) - if os.path.exists(self.openerp_dir): - shutil.rmtree(self.openerp_dir) + logger.info("Cleaning existing %s", self.odoo_dir) + if os.path.exists(self.odoo_dir): + shutil.rmtree(self.odoo_dir) logger.info(u'Extracting %s ...' % self.archive_path) self.sandboxed_tar_extract(extracted_name, tar, first=first) tar.close() @@ -1058,7 +1058,7 @@ def retrieve_main_software(self): options.update(source[2]) if self.clean: options['clean'] = True - vcs.get_update(type_spec, self.openerp_dir, url, rev, + vcs.get_update(type_spec, self.odoo_dir, url, rev, offline=self.offline, clear_retry=self.clear_retry, **options) @@ -1093,7 +1093,7 @@ def install(self): self.retrieve_merges() self.install_recipe_requirements() - os.chdir(self.openerp_dir) # GR probably not needed any more + os.chdir(self.odoo_dir) # GR probably not needed any more self.read_openerp_setup() if (self.sources[main_software][0] == 'downloadable' and @@ -1177,8 +1177,8 @@ def freeze_to(self, out_config_path): if source_type == 'downloadable': self._freeze_downloadable_main_software(out_conf) else: # vcs - abspath = self.openerp_dir - self.cleanup_openerp_dir() + abspath = self.odoo_dir + self.cleanup_odoo_dir() else: abspath = self.make_absolute(local_path) @@ -1507,20 +1507,20 @@ def _extract_main_software(self, source_type, target_dir, extracted): The extracted set avoids extracting twice to same target (refused by some VCSes anyway) """ - if not self.openerp_dir.startswith(self.buildout_dir): + if not self.odoo_dir.startswith(self.buildout_dir): raise RuntimeError( "Main openerp directory %r outside of buildout " - "directory, don't know how to handle that" % self.openerp_dir) + "directory, don't know how to handle that" % self.odoo_dir) - local_path = self.openerp_dir[len(self.buildout_dir + os.sep):] + local_path = self.odoo_dir[len(self.buildout_dir + os.sep):] target_path = join(target_dir, local_path) if target_path in extracted: return local_path if source_type == 'downloadable': - shutil.copytree(self.openerp_dir, target_path) + shutil.copytree(self.odoo_dir, target_path) elif source_type != 'local': # see docstring for 'local' - self._extract_vcs_source(source_type, self.openerp_dir, target_dir, + self._extract_vcs_source(source_type, self.odoo_dir, target_dir, local_path, extracted) return local_path @@ -1605,7 +1605,7 @@ def finalize_addons_paths(self, check_existence=True): "please use addons lines with type 'local' " "instead." % (self.name, opt_key)) - base_addons = join(self.openerp_dir, 'openerp', 'addons') + base_addons = join(self.odoo_dir, 'odoo', 'addons') if os.path.exists(base_addons): self.addons_paths.insert(0, base_addons) @@ -1647,7 +1647,7 @@ def insert_odoo_git_addons(self, base_addons): :param base_addons: the path to previously detected ``base`` addons, to properly insert right after them """ - odoo_git_addons = join(self.openerp_dir, 'addons') + odoo_git_addons = join(self.odoo_dir, 'addons') if not os.path.isdir(odoo_git_addons): return @@ -1663,7 +1663,7 @@ def insert_odoo_git_addons(self, base_addons): except ValueError: addons_paths.insert(insert_at, odoo_git_addons) - def cleanup_openerp_dir(self): + def cleanup_odoo_dir(self): """Revert local modifications that have been made during installation. These can be, e.g., forbidden by the freeze process.""" @@ -1673,7 +1673,7 @@ def cleanup_openerp_dir(self): # It is in practice now, but one day, the extraction as a separate # script of freeze/extract will become a reality. for proj_name in ('openerp', 'odoo'): - egg_info_dir = join(self.openerp_dir, proj_name + '.egg-info') + egg_info_dir = join(self.odoo_dir, proj_name + '.egg-info') if os.path.exists(egg_info_dir): shutil.rmtree(egg_info_dir) From a962919508c9b0936eb8bd9b4f9098a25e965abf Mon Sep 17 00:00:00 2001 From: archetipo Date: Tue, 27 Sep 2016 11:50:57 +0200 Subject: [PATCH 04/33] [FIX] prj name odoo --- anybox/recipe/odoo/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anybox/recipe/odoo/base.py b/anybox/recipe/odoo/base.py index e03a665a..e33d7941 100644 --- a/anybox/recipe/odoo/base.py +++ b/anybox/recipe/odoo/base.py @@ -1672,7 +1672,7 @@ def cleanup_odoo_dir(self): # Nothing guarantees that this method is called after develop(). # It is in practice now, but one day, the extraction as a separate # script of freeze/extract will become a reality. - for proj_name in ('openerp', 'odoo'): + for proj_name in ('odoo', 'odoo'): egg_info_dir = join(self.odoo_dir, proj_name + '.egg-info') if os.path.exists(egg_info_dir): shutil.rmtree(egg_info_dir) From b9b83b3d9dc562990c276782dba2df98b422486b Mon Sep 17 00:00:00 2001 From: archetipo Date: Tue, 27 Sep 2016 12:07:10 +0200 Subject: [PATCH 05/33] Revert "[FIX] prj name odoo" This reverts commit 53b323fe4eb85d19a600dcd19350007bf2da2129. --- anybox/recipe/odoo/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anybox/recipe/odoo/base.py b/anybox/recipe/odoo/base.py index e33d7941..e03a665a 100644 --- a/anybox/recipe/odoo/base.py +++ b/anybox/recipe/odoo/base.py @@ -1672,7 +1672,7 @@ def cleanup_odoo_dir(self): # Nothing guarantees that this method is called after develop(). # It is in practice now, but one day, the extraction as a separate # script of freeze/extract will become a reality. - for proj_name in ('odoo', 'odoo'): + for proj_name in ('openerp', 'odoo'): egg_info_dir = join(self.odoo_dir, proj_name + '.egg-info') if os.path.exists(egg_info_dir): shutil.rmtree(egg_info_dir) From 3d7cdc0499ff01d1106aa9d3a20263d5f5181f0f Mon Sep 17 00:00:00 2001 From: archetipo Date: Tue, 27 Sep 2016 12:07:35 +0200 Subject: [PATCH 06/33] Revert "[FIX] path odoo/addons" This reverts commit 03acb98923e4776674b8c0a0cb9763c1c094e496. --- anybox/recipe/odoo/base.py | 54 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/anybox/recipe/odoo/base.py b/anybox/recipe/odoo/base.py index e03a665a..cb75a2e5 100644 --- a/anybox/recipe/odoo/base.py +++ b/anybox/recipe/odoo/base.py @@ -207,11 +207,11 @@ def __init__(self, buildout, name, options): self.options['extra-paths'] = os.linesep.join(self.extra_paths) self.downloads_dir = self.make_absolute( - self.b_options.get('odoo-downloads-directory', 'downloads')) + self.b_options.get('openerp-downloads-directory', 'downloads')) self.version_wanted = None # from the buildout self.version_detected = None # string from the openerp setup.py self.parts = self.buildout['buildout']['parts-directory'] - self.odoo_dir = None + self.openerp_dir = None self.archive_filename = None self.archive_path = None # downloaded tar.gz @@ -275,7 +275,7 @@ def parse_version(self): # in all other cases, the first token is the type of version type_spec = version_split[0] if type_spec in ('local', 'path'): - self.odoo_dir = join(self.buildout_dir, version_split[1]) + self.openerp_dir = join(self.buildout_dir, version_split[1]) self.sources[main_software] = ('local', None) elif type_spec == 'url': url = version_split[1] @@ -305,7 +305,7 @@ def parse_version(self): # VCS types type_spec, url, repo_dir, self.version_wanted = version_split[0:4] options = dict(opt.split('=') for opt in version_split[4:]) - self.odoo_dir = join(self.parts, repo_dir) + self.openerp_dir = join(self.parts, repo_dir) self.sources[main_software] = (type_spec, (url, self.version_wanted), options) @@ -379,7 +379,7 @@ def apply_odoo_requirements_file(self): more complicated. """ req_fname = 'requirements.txt' - req_path = join(self.odoo_dir, req_fname) + req_path = join(self.openerp_dir, req_fname) if not os.path.exists(req_path): logger.warn("%r not found in this version of " "Odoo, although the configuration said to use it. " @@ -614,7 +614,7 @@ def read_release(self): in an old OpenERP version. Could become the norm, but setup is also used to list dependencies. """ - with open(join(self.odoo_dir, 'bin', 'release.py'), 'rb') as f: + with open(join(self.openerp_dir, 'bin', 'release.py'), 'rb') as f: mod = imp.load_module('release', f, 'release.py', ('.py', 'r', imp.PY_SOURCE)) self.version_detected = mod.version @@ -633,7 +633,7 @@ def new_setup(*args, **kw): setuptools.setup = new_setup distutils.core.setup = new_setup sys.path.insert(0, '.') - with open(join(self.odoo_dir, 'setup.py'), 'rb') as f: + with open(join(self.openerp_dir, 'setup.py'), 'rb') as f: saved_argv = sys.argv sys.argv = ['setup.py', 'develop'] try: @@ -912,7 +912,7 @@ def revert_sources(self): continue vcs_type, vcs_spec, options = desc - local_dir = self.odoo_dir if target is main_software else target + local_dir = self.openerp_dir if target is main_software else target local_dir = self.make_absolute(local_dir) repo = vcs.repo(vcs_type, local_dir, vcs_spec[0], **options) try: @@ -1020,7 +1020,7 @@ def retrieve_main_software(self): if type_spec == 'local': logger.info('Local directory chosen, nothing to do') if self.clean: - utils.clean_object_files(self.odoo_dir) + utils.clean_object_files(self.openerp_dir) elif type_spec == 'downloadable': # download if needed if ((self.archive_path and @@ -1037,14 +1037,14 @@ def retrieve_main_software(self): # as openerp-6.1-1 assert(first.isdir()) extracted_name = first.name.split('/')[0] - self.odoo_dir = join(self.parts, extracted_name) + self.openerp_dir = join(self.parts, extracted_name) # protection against malicious tarballs assert(not os.path.isabs(extracted_name)) - assert(self.odoo_dir.startswith(self.parts)) + assert(self.openerp_dir.startswith(self.parts)) - logger.info("Cleaning existing %s", self.odoo_dir) - if os.path.exists(self.odoo_dir): - shutil.rmtree(self.odoo_dir) + logger.info("Cleaning existing %s", self.openerp_dir) + if os.path.exists(self.openerp_dir): + shutil.rmtree(self.openerp_dir) logger.info(u'Extracting %s ...' % self.archive_path) self.sandboxed_tar_extract(extracted_name, tar, first=first) tar.close() @@ -1058,7 +1058,7 @@ def retrieve_main_software(self): options.update(source[2]) if self.clean: options['clean'] = True - vcs.get_update(type_spec, self.odoo_dir, url, rev, + vcs.get_update(type_spec, self.openerp_dir, url, rev, offline=self.offline, clear_retry=self.clear_retry, **options) @@ -1093,7 +1093,7 @@ def install(self): self.retrieve_merges() self.install_recipe_requirements() - os.chdir(self.odoo_dir) # GR probably not needed any more + os.chdir(self.openerp_dir) # GR probably not needed any more self.read_openerp_setup() if (self.sources[main_software][0] == 'downloadable' and @@ -1177,8 +1177,8 @@ def freeze_to(self, out_config_path): if source_type == 'downloadable': self._freeze_downloadable_main_software(out_conf) else: # vcs - abspath = self.odoo_dir - self.cleanup_odoo_dir() + abspath = self.openerp_dir + self.cleanup_openerp_dir() else: abspath = self.make_absolute(local_path) @@ -1507,20 +1507,20 @@ def _extract_main_software(self, source_type, target_dir, extracted): The extracted set avoids extracting twice to same target (refused by some VCSes anyway) """ - if not self.odoo_dir.startswith(self.buildout_dir): + if not self.openerp_dir.startswith(self.buildout_dir): raise RuntimeError( "Main openerp directory %r outside of buildout " - "directory, don't know how to handle that" % self.odoo_dir) + "directory, don't know how to handle that" % self.openerp_dir) - local_path = self.odoo_dir[len(self.buildout_dir + os.sep):] + local_path = self.openerp_dir[len(self.buildout_dir + os.sep):] target_path = join(target_dir, local_path) if target_path in extracted: return local_path if source_type == 'downloadable': - shutil.copytree(self.odoo_dir, target_path) + shutil.copytree(self.openerp_dir, target_path) elif source_type != 'local': # see docstring for 'local' - self._extract_vcs_source(source_type, self.odoo_dir, target_dir, + self._extract_vcs_source(source_type, self.openerp_dir, target_dir, local_path, extracted) return local_path @@ -1605,7 +1605,7 @@ def finalize_addons_paths(self, check_existence=True): "please use addons lines with type 'local' " "instead." % (self.name, opt_key)) - base_addons = join(self.odoo_dir, 'odoo', 'addons') + base_addons = join(self.openerp_dir, 'openerp', 'addons') if os.path.exists(base_addons): self.addons_paths.insert(0, base_addons) @@ -1647,7 +1647,7 @@ def insert_odoo_git_addons(self, base_addons): :param base_addons: the path to previously detected ``base`` addons, to properly insert right after them """ - odoo_git_addons = join(self.odoo_dir, 'addons') + odoo_git_addons = join(self.openerp_dir, 'addons') if not os.path.isdir(odoo_git_addons): return @@ -1663,7 +1663,7 @@ def insert_odoo_git_addons(self, base_addons): except ValueError: addons_paths.insert(insert_at, odoo_git_addons) - def cleanup_odoo_dir(self): + def cleanup_openerp_dir(self): """Revert local modifications that have been made during installation. These can be, e.g., forbidden by the freeze process.""" @@ -1673,7 +1673,7 @@ def cleanup_odoo_dir(self): # It is in practice now, but one day, the extraction as a separate # script of freeze/extract will become a reality. for proj_name in ('openerp', 'odoo'): - egg_info_dir = join(self.odoo_dir, proj_name + '.egg-info') + egg_info_dir = join(self.openerp_dir, proj_name + '.egg-info') if os.path.exists(egg_info_dir): shutil.rmtree(egg_info_dir) From 9e77c39e3952adccadea05ce082938238dd8a4e6 Mon Sep 17 00:00:00 2001 From: archetipo Date: Wed, 28 Sep 2016 09:47:39 +0200 Subject: [PATCH 07/33] [fix] openerp -> odoo --- anybox/recipe/odoo/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/anybox/recipe/odoo/base.py b/anybox/recipe/odoo/base.py index cb75a2e5..fa3ab2b8 100644 --- a/anybox/recipe/odoo/base.py +++ b/anybox/recipe/odoo/base.py @@ -1605,7 +1605,7 @@ def finalize_addons_paths(self, check_existence=True): "please use addons lines with type 'local' " "instead." % (self.name, opt_key)) - base_addons = join(self.openerp_dir, 'openerp', 'addons') + base_addons = join(self.openerp_dir, 'odoo', 'addons') if os.path.exists(base_addons): self.addons_paths.insert(0, base_addons) @@ -1672,7 +1672,7 @@ def cleanup_openerp_dir(self): # Nothing guarantees that this method is called after develop(). # It is in practice now, but one day, the extraction as a separate # script of freeze/extract will become a reality. - for proj_name in ('openerp', 'odoo'): + for proj_name in ('odoo', 'odoo'): egg_info_dir = join(self.openerp_dir, proj_name + '.egg-info') if os.path.exists(egg_info_dir): shutil.rmtree(egg_info_dir) From c24d04bc56500d70c4c2dd05a5b74c98ad4ff394 Mon Sep 17 00:00:00 2001 From: archetipo Date: Wed, 28 Sep 2016 09:55:27 +0200 Subject: [PATCH 08/33] Revert "[fix] openerp -> odoo" This reverts commit 7e430acc3ff7a74f6b15ddcba5398fd4ba253bd2. --- anybox/recipe/odoo/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/anybox/recipe/odoo/base.py b/anybox/recipe/odoo/base.py index fa3ab2b8..cb75a2e5 100644 --- a/anybox/recipe/odoo/base.py +++ b/anybox/recipe/odoo/base.py @@ -1605,7 +1605,7 @@ def finalize_addons_paths(self, check_existence=True): "please use addons lines with type 'local' " "instead." % (self.name, opt_key)) - base_addons = join(self.openerp_dir, 'odoo', 'addons') + base_addons = join(self.openerp_dir, 'openerp', 'addons') if os.path.exists(base_addons): self.addons_paths.insert(0, base_addons) @@ -1672,7 +1672,7 @@ def cleanup_openerp_dir(self): # Nothing guarantees that this method is called after develop(). # It is in practice now, but one day, the extraction as a separate # script of freeze/extract will become a reality. - for proj_name in ('odoo', 'odoo'): + for proj_name in ('openerp', 'odoo'): egg_info_dir = join(self.openerp_dir, proj_name + '.egg-info') if os.path.exists(egg_info_dir): shutil.rmtree(egg_info_dir) From 7f9f8f0ed20e3191ce27ac93657a202f5c7684df Mon Sep 17 00:00:00 2001 From: archetipo Date: Wed, 28 Sep 2016 10:02:50 +0200 Subject: [PATCH 09/33] fix odoo-server --- anybox/recipe/odoo/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anybox/recipe/odoo/server.py b/anybox/recipe/odoo/server.py index cc110f7d..bea48b12 100644 --- a/anybox/recipe/odoo/server.py +++ b/anybox/recipe/odoo/server.py @@ -183,7 +183,7 @@ def _create_gunicorn_conf(self, qualified_name): def _get_server_command(self): """Return a full path to the main Odoo server command.""" - return join(self.openerp_dir, 'openerp-server') + return join(self.openerp_dir, 'odoo-server') def _parse_openerp_scripts(self): """Parse required scripts from conf.""" From b215fd8d2792c582f1bee41b1d1c62d47514117a Mon Sep 17 00:00:00 2001 From: archetipo Date: Wed, 28 Sep 2016 10:06:52 +0200 Subject: [PATCH 10/33] Revert "fix odoo-server" This reverts commit a0f201e95fee1a8f6faa4073e159187b8b9879f6. --- anybox/recipe/odoo/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anybox/recipe/odoo/server.py b/anybox/recipe/odoo/server.py index bea48b12..cc110f7d 100644 --- a/anybox/recipe/odoo/server.py +++ b/anybox/recipe/odoo/server.py @@ -183,7 +183,7 @@ def _create_gunicorn_conf(self, qualified_name): def _get_server_command(self): """Return a full path to the main Odoo server command.""" - return join(self.openerp_dir, 'odoo-server') + return join(self.openerp_dir, 'openerp-server') def _parse_openerp_scripts(self): """Parse required scripts from conf.""" From e1a4faabf19efb8618ef173e43e02abd27e79157 Mon Sep 17 00:00:00 2001 From: archetipo Date: Wed, 28 Sep 2016 10:07:29 +0200 Subject: [PATCH 11/33] fix openerp-server -> odoo-bin --- anybox/recipe/odoo/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anybox/recipe/odoo/server.py b/anybox/recipe/odoo/server.py index cc110f7d..0058db95 100644 --- a/anybox/recipe/odoo/server.py +++ b/anybox/recipe/odoo/server.py @@ -183,7 +183,7 @@ def _create_gunicorn_conf(self, qualified_name): def _get_server_command(self): """Return a full path to the main Odoo server command.""" - return join(self.openerp_dir, 'openerp-server') + return join(self.openerp_dir, 'odoo-bin') def _parse_openerp_scripts(self): """Parse required scripts from conf.""" From 067945cf039d6460ddaf3a0fa2b2a2d03562d1e7 Mon Sep 17 00:00:00 2001 From: archetipo Date: Tue, 4 Oct 2016 07:55:22 +0200 Subject: [PATCH 12/33] try to fix tests --- .gitignore | 1 + anybox/recipe/odoo/base.py | 99 +++++------ anybox/recipe/odoo/runtime/session.py | 22 +-- anybox/recipe/odoo/server.py | 112 ++++++------ anybox/recipe/odoo/testing.py | 8 +- .../tests/integration_buildouts/buildout.cfg | 2 +- .../buildout_with_versions.cfg | 2 +- .../openerp-gevent => odoo10/odoo-bin} | 0 .../openerp-server => odoo10/odoo-gevent} | 0 .../{odoo80 => odoo10}/odoo.py | 0 .../openerp => odoo10/odoo}/__init__.py | 0 .../odoo10/odoo}/release.py | 14 +- .../openerp => odoo10/odoo}/tools/__init__.py | 0 .../openerp => odoo10/odoo}/tools/config.py | 0 .../{odoo80 => odoo10}/requirements.txt | 0 .../odoo10}/setup.py | 14 +- .../integration_buildouts/odoo80/setup.py | 75 -------- .../{openerp-gevent => odoo-bin} | 0 .../{openerp-server => odoo-gevent} | 0 .../{openerp => odoo}/__init__.py | 0 .../odoo}/release.py | 4 +- .../odoo/tests/odoo-project-renaming/setup.py | 14 +- .../openerp-gevent => odoo10/odoo-bin} | 0 .../openerp-server => odoo10/odoo-gevent} | 0 .../odoo/tests/{odoo80 => odoo10}/odoo.py | 0 .../openerp => odoo10/odoo}/__init__.py | 0 .../openerp => odoo10/odoo}/release.py | 14 +- anybox/recipe/odoo/tests/odoo10/setup.py | 167 ++++++++++++++++++ anybox/recipe/odoo/tests/test_base.py | 105 +++++------ anybox/recipe/odoo/tests/test_extract.py | 20 +-- anybox/recipe/odoo/tests/test_freeze.py | 22 +-- .../odoo/tests/test_integration_server.py | 2 +- anybox/recipe/odoo/tests/test_server.py | 164 ++++++++--------- buildbot/MANIFEST.cfg | 8 +- buildbot/recipe-10.cfg | 9 + .../README.txt | 0 .../data/VERSION.txt | 0 .../test_session.py | 2 +- .../test_version.py | 2 +- 39 files changed, 486 insertions(+), 396 deletions(-) rename anybox/recipe/odoo/tests/integration_buildouts/{odoo80/openerp-gevent => odoo10/odoo-bin} (100%) rename anybox/recipe/odoo/tests/integration_buildouts/{odoo80/openerp-server => odoo10/odoo-gevent} (100%) rename anybox/recipe/odoo/tests/integration_buildouts/{odoo80 => odoo10}/odoo.py (100%) rename anybox/recipe/odoo/tests/integration_buildouts/{odoo80/openerp => odoo10/odoo}/__init__.py (100%) rename anybox/recipe/odoo/tests/{odoo-project-renaming/openerp => integration_buildouts/odoo10/odoo}/release.py (86%) rename anybox/recipe/odoo/tests/integration_buildouts/{odoo80/openerp => odoo10/odoo}/tools/__init__.py (100%) rename anybox/recipe/odoo/tests/integration_buildouts/{odoo80/openerp => odoo10/odoo}/tools/config.py (100%) rename anybox/recipe/odoo/tests/integration_buildouts/{odoo80 => odoo10}/requirements.txt (100%) rename anybox/recipe/odoo/tests/{odoo80 => integration_buildouts/odoo10}/setup.py (93%) delete mode 100644 anybox/recipe/odoo/tests/integration_buildouts/odoo80/setup.py rename anybox/recipe/odoo/tests/odoo-project-renaming/{openerp-gevent => odoo-bin} (100%) rename anybox/recipe/odoo/tests/odoo-project-renaming/{openerp-server => odoo-gevent} (100%) rename anybox/recipe/odoo/tests/odoo-project-renaming/{openerp => odoo}/__init__.py (100%) rename anybox/recipe/odoo/tests/{integration_buildouts/odoo80/openerp => odoo-project-renaming/odoo}/release.py (96%) rename anybox/recipe/odoo/tests/{odoo80/openerp-gevent => odoo10/odoo-bin} (100%) rename anybox/recipe/odoo/tests/{odoo80/openerp-server => odoo10/odoo-gevent} (100%) rename anybox/recipe/odoo/tests/{odoo80 => odoo10}/odoo.py (100%) rename anybox/recipe/odoo/tests/{odoo80/openerp => odoo10/odoo}/__init__.py (100%) rename anybox/recipe/odoo/tests/{odoo80/openerp => odoo10/odoo}/release.py (86%) create mode 100644 anybox/recipe/odoo/tests/odoo10/setup.py create mode 100644 buildbot/recipe-10.cfg rename {tests_with_openerp => tests_with_odoo}/README.txt (100%) rename {tests_with_openerp => tests_with_odoo}/data/VERSION.txt (100%) rename {tests_with_openerp => tests_with_odoo}/test_session.py (95%) rename {tests_with_openerp => tests_with_odoo}/test_version.py (97%) diff --git a/.gitignore b/.gitignore index 8c72bd0a..15eef694 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ buildbot/develop-eggs/ buildbot/etc/ buildbot/parts/ doc/sphinx_build +.eggs diff --git a/anybox/recipe/odoo/base.py b/anybox/recipe/odoo/base.py index cb75a2e5..8d4f8a6d 100644 --- a/anybox/recipe/odoo/base.py +++ b/anybox/recipe/odoo/base.py @@ -137,7 +137,7 @@ class BaseRecipe(object): """ nightly_dl_url = { - '8.0': 'http://nightly.odoo.com/8.0/nightly/src/', + '10.0rc1c': 'http://nightly.odoo.com/10.0/nightly/src/', } """Base URLs to look for nightly versions. @@ -158,7 +158,7 @@ class BaseRecipe(object): """True if this is the git layout, as seen from the move to GitHub. In this layout, the standard addons other than ``base`` are in a ``addons`` - directory right next to the ``openerp`` package. + directory right next to the ``odoo`` package. """ with_odoo_requirements_file = False @@ -207,11 +207,11 @@ def __init__(self, buildout, name, options): self.options['extra-paths'] = os.linesep.join(self.extra_paths) self.downloads_dir = self.make_absolute( - self.b_options.get('openerp-downloads-directory', 'downloads')) + self.b_options.get('odoo-downloads-directory', 'downloads')) self.version_wanted = None # from the buildout - self.version_detected = None # string from the openerp setup.py + self.version_detected = None # string from the odoo setup.py self.parts = self.buildout['buildout']['parts-directory'] - self.openerp_dir = None + self.odoo_dir = None self.archive_filename = None self.archive_path = None # downloaded tar.gz @@ -227,7 +227,7 @@ def __init__(self, buildout, name, options): "system-wide is a good option. "), } - self.openerp_installed = [] + self.odoo_installed = [] self.etc = self.make_absolute(options.get('etc-directory', 'etc')) self.bin_dir = self.buildout['buildout']['bin-directory'] @@ -257,7 +257,7 @@ def parse_version(self): if len(version_split) == 1: # version can be a simple version name, such as 6.1-1 - major_wanted = self.version_wanted[:3] + major_wanted = self.version_wanted[:4] pattern = self.release_filenames[major_wanted] if pattern is None: raise UserError('Odoo version %r' @@ -275,7 +275,7 @@ def parse_version(self): # in all other cases, the first token is the type of version type_spec = version_split[0] if type_spec in ('local', 'path'): - self.openerp_dir = join(self.buildout_dir, version_split[1]) + self.odoo_dir = join(self.buildout_dir, version_split[1]) self.sources[main_software] = ('local', None) elif type_spec == 'url': url = version_split[1] @@ -305,7 +305,7 @@ def parse_version(self): # VCS types type_spec, url, repo_dir, self.version_wanted = version_split[0:4] options = dict(opt.split('=') for opt in version_split[4:]) - self.openerp_dir = join(self.parts, repo_dir) + self.odoo_dir = join(self.parts, repo_dir) self.sources[main_software] = (type_spec, (url, self.version_wanted), options) @@ -379,7 +379,7 @@ def apply_odoo_requirements_file(self): more complicated. """ req_fname = 'requirements.txt' - req_path = join(self.openerp_dir, req_fname) + req_path = join(self.odoo_dir, req_fname) if not os.path.exists(req_path): logger.warn("%r not found in this version of " "Odoo, although the configuration said to use it. " @@ -614,12 +614,12 @@ def read_release(self): in an old OpenERP version. Could become the norm, but setup is also used to list dependencies. """ - with open(join(self.openerp_dir, 'bin', 'release.py'), 'rb') as f: + with open(join(self.odoo_dir, 'bin', 'release.py'), 'rb') as f: mod = imp.load_module('release', f, 'release.py', ('.py', 'r', imp.PY_SOURCE)) self.version_detected = mod.version - def read_openerp_setup(self): + def read_odoo_setup(self): """Ugly method to extract requirements & version from ugly setup.py. Primarily designed for 6.0, but works with 6.1 as well. @@ -633,7 +633,7 @@ def new_setup(*args, **kw): setuptools.setup = new_setup distutils.core.setup = new_setup sys.path.insert(0, '.') - with open(join(self.openerp_dir, 'setup.py'), 'rb') as f: + with open(join(self.odoo_dir, 'setup.py'), 'rb') as f: saved_argv = sys.argv sys.argv = ['setup.py', 'develop'] try: @@ -686,7 +686,7 @@ def sandboxed_tar_extract(self, sandbox, tarfile, first=None): The tarfile module official doc warns against attacks with .. in tar. The option to start with a first member is useful for this case, since - the recipe consumes a first member in the tar file to get the openerp + the recipe consumes a first member in the tar file to get the odoo main directory in parts. It is taken for granted that this first member has already been checked. @@ -844,7 +844,6 @@ def retrieve_addons(self): for local_dir, source_spec in self.sources.items(): if local_dir is main_software: continue - loc_type, loc_spec, addons_options = source_spec local_dir = self.make_absolute(local_dir) options = dict(offline=self.offline, @@ -892,7 +891,7 @@ def retrieve_addons(self): if subdir: addons_dir = join(addons_dir, subdir) - manifest = os.path.join(addons_dir, '__openerp__.py') + manifest = os.path.join(addons_dir, '__odoo__.py') manifest_pre_v6 = os.path.join(addons_dir, '__terp__.py') if os.path.isfile(manifest) or os.path.isfile(manifest_pre_v6): raise UserError("Standalone addons such as %r " @@ -912,7 +911,7 @@ def revert_sources(self): continue vcs_type, vcs_spec, options = desc - local_dir = self.openerp_dir if target is main_software else target + local_dir = self.odoo_dir if target is main_software else target local_dir = self.make_absolute(local_dir) repo = vcs.repo(vcs_type, local_dir, vcs_spec[0], **options) try: @@ -1020,7 +1019,7 @@ def retrieve_main_software(self): if type_spec == 'local': logger.info('Local directory chosen, nothing to do') if self.clean: - utils.clean_object_files(self.openerp_dir) + utils.clean_object_files(self.odoo_dir) elif type_spec == 'downloadable': # download if needed if ((self.archive_path and @@ -1034,17 +1033,17 @@ def retrieve_main_software(self): first = tar.next() # Everything that follows assumes all tarball members # are inside a directory with an expected name such - # as openerp-6.1-1 + # as odoo-6.1-1 assert(first.isdir()) extracted_name = first.name.split('/')[0] - self.openerp_dir = join(self.parts, extracted_name) + self.odoo_dir = join(self.parts, extracted_name) # protection against malicious tarballs assert(not os.path.isabs(extracted_name)) - assert(self.openerp_dir.startswith(self.parts)) + assert(self.odoo_dir.startswith(self.parts)) - logger.info("Cleaning existing %s", self.openerp_dir) - if os.path.exists(self.openerp_dir): - shutil.rmtree(self.openerp_dir) + logger.info("Cleaning existing %s", self.odoo_dir) + if os.path.exists(self.odoo_dir): + shutil.rmtree(self.odoo_dir) logger.info(u'Extracting %s ...' % self.archive_path) self.sandboxed_tar_extract(extracted_name, tar, first=first) tar.close() @@ -1058,15 +1057,15 @@ def retrieve_main_software(self): options.update(source[2]) if self.clean: options['clean'] = True - vcs.get_update(type_spec, self.openerp_dir, url, rev, + vcs.get_update(type_spec, self.odoo_dir, url, rev, offline=self.offline, clear_retry=self.clear_retry, **options) def _register_extra_paths(self): - """Add openerp paths into the extra-paths (used in scripts' sys.path). + """Add odoo paths into the extra-paths (used in scripts' sys.path). This is useful up to the 6.0 series only, because in later version, - the 'openerp' directory is a proper distribution that we develop, with + the 'odoo' directory is a proper distribution that we develop, with the effect of putting it on the path automatically. """ extra = self.extra_paths @@ -1093,8 +1092,8 @@ def install(self): self.retrieve_merges() self.install_recipe_requirements() - os.chdir(self.openerp_dir) # GR probably not needed any more - self.read_openerp_setup() + os.chdir(self.odoo_dir) # GR probably not needed any more + self.read_odoo_setup() if (self.sources[main_software][0] == 'downloadable' and self.version_wanted == 'latest'): @@ -1136,7 +1135,7 @@ def install(self): self.extract_downloads_to(extract_downloads_to) if freeze_to: self.freeze_to(freeze_to) - return self.openerp_installed + return self.odoo_installed def dump_nightly_latest_version(self): """After download/analysis of 'nightly latest', give equivalent spec. @@ -1151,9 +1150,9 @@ def freeze_to(self, out_config_path): out_config_path) out_conf = ConfigParser.ConfigParser() - frozen = getattr(self.buildout, '_openerp_recipe_frozen', None) + frozen = getattr(self.buildout, '_odoo_recipe_frozen', None) if frozen is None: - frozen = self.buildout._openerp_recipe_frozen = set() + frozen = self.buildout._odoo_recipe_frozen = set() if out_config_path in frozen: # read configuration started by other recipe @@ -1177,8 +1176,8 @@ def freeze_to(self, out_config_path): if source_type == 'downloadable': self._freeze_downloadable_main_software(out_conf) else: # vcs - abspath = self.openerp_dir - self.cleanup_openerp_dir() + abspath = self.odoo_dir + self.cleanup_odoo_dir() else: abspath = self.make_absolute(local_path) @@ -1377,10 +1376,10 @@ def extract_downloads_to(self, target_dir, outconf_name='release.cfg'): target_dir = self.make_absolute(target_dir) out_conf = ConfigParser.ConfigParser() - all_extracted = getattr(self.buildout, '_openerp_recipe_extracted', + all_extracted = getattr(self.buildout, '_odoo_recipe_extracted', None) if all_extracted is None: - all_extracted = self.buildout._openerp_recipe_extracted = {} + all_extracted = self.buildout._odoo_recipe_extracted = {} out_config_path = join(target_dir, outconf_name) # GR TODO this will fail if same target dir has been used with @@ -1507,20 +1506,20 @@ def _extract_main_software(self, source_type, target_dir, extracted): The extracted set avoids extracting twice to same target (refused by some VCSes anyway) """ - if not self.openerp_dir.startswith(self.buildout_dir): + if not self.odoo_dir.startswith(self.buildout_dir): raise RuntimeError( - "Main openerp directory %r outside of buildout " - "directory, don't know how to handle that" % self.openerp_dir) + "Main odoo directory %r outside of buildout " + "directory, don't know how to handle that" % self.odoo_dir) - local_path = self.openerp_dir[len(self.buildout_dir + os.sep):] + local_path = self.odoo_dir[len(self.buildout_dir + os.sep):] target_path = join(target_dir, local_path) if target_path in extracted: return local_path if source_type == 'downloadable': - shutil.copytree(self.openerp_dir, target_path) + shutil.copytree(self.odoo_dir, target_path) elif source_type != 'local': # see docstring for 'local' - self._extract_vcs_source(source_type, self.openerp_dir, target_dir, + self._extract_vcs_source(source_type, self.odoo_dir, target_dir, local_path, extracted) return local_path @@ -1576,7 +1575,7 @@ def _install_script(self, name, content): f.write(content) f.close() os.chmod(path, stat.S_IRWXU) - self.openerp_installed.append(path) + self.odoo_installed.append(path) return path def _install_startup_scripts(self): @@ -1605,7 +1604,7 @@ def finalize_addons_paths(self, check_existence=True): "please use addons lines with type 'local' " "instead." % (self.name, opt_key)) - base_addons = join(self.openerp_dir, 'openerp', 'addons') + base_addons = join(self.odoo_dir, 'odoo', 'addons') if os.path.exists(base_addons): self.addons_paths.insert(0, base_addons) @@ -1622,7 +1621,7 @@ def insert_odoo_git_addons(self, base_addons): """Insert the standard, non-base addons bundled within Odoo git repo. See `lp:1327756 - `_ + `_ These addons are also part of the Github branch for prior versions, therefore we cannot rely on version knowledge; we check for existence @@ -1647,7 +1646,7 @@ def insert_odoo_git_addons(self, base_addons): :param base_addons: the path to previously detected ``base`` addons, to properly insert right after them """ - odoo_git_addons = join(self.openerp_dir, 'addons') + odoo_git_addons = join(self.odoo_dir, 'addons') if not os.path.isdir(odoo_git_addons): return @@ -1663,17 +1662,17 @@ def insert_odoo_git_addons(self, base_addons): except ValueError: addons_paths.insert(insert_at, odoo_git_addons) - def cleanup_openerp_dir(self): + def cleanup_odoo_dir(self): """Revert local modifications that have been made during installation. These can be, e.g., forbidden by the freeze process.""" - # from here we can't guess whether it's 'openerp' or 'odoo'. + # from here we can't guess whether it's 'odoo' or 'odoo'. # Nothing guarantees that this method is called after develop(). # It is in practice now, but one day, the extraction as a separate # script of freeze/extract will become a reality. - for proj_name in ('openerp', 'odoo'): - egg_info_dir = join(self.openerp_dir, proj_name + '.egg-info') + for proj_name in ('odoo', 'odoo'): + egg_info_dir = join(self.odoo_dir, proj_name + '.egg-info') if os.path.exists(egg_info_dir): shutil.rmtree(egg_info_dir) diff --git a/anybox/recipe/odoo/runtime/session.py b/anybox/recipe/odoo/runtime/session.py index 82c43e7c..f6b6d6b0 100644 --- a/anybox/recipe/odoo/runtime/session.py +++ b/anybox/recipe/odoo/runtime/session.py @@ -29,7 +29,7 @@ DEFAULT_VERSION_FILE = 'VERSION.txt' -class OpenERPVersion(Version): +class OdooVersion(Version): """Odoo idea of version, wrapped in a class. This is based on :meth:`odoo.tools.parse_version`, and @@ -38,7 +38,7 @@ class OpenERPVersion(Version): """ def parse(self, incoming): - if isinstance(incoming, OpenERPVersion): + if isinstance(incoming, OdooVersion): self.vstring = incoming.vstring self.components = incoming.components else: @@ -49,7 +49,7 @@ def __str__(self): return self.vstring def __repr__(self): - return 'OpenERPVersion(%r)' % str(self) + return 'OdooVersion(%r)' % str(self) def __cmp__(self, other): if isinstance(other, tuple): @@ -190,7 +190,7 @@ def init_environments(self): See :class:``openerp.api.Environment`` for explanations about environments. - For OpenERP/Odoo versions prior to the new style API merge, this + For Odoo/Odoo versions prior to the new style API merge, this is a no-op. This thread-local ``environments`` is initialized and cleaned with @@ -269,7 +269,7 @@ def parse_version_string(self, vstring): for applications whose life started before this set of utilities has been used : this helps building an usable default. """ - return OpenERPVersion(vstring) + return OdooVersion(vstring) @property def db_version(self): @@ -291,7 +291,7 @@ def db_version(self): # restoring sanity ASAP db_version = None else: - db_version = OpenERPVersion(db_version) + db_version = OdooVersion(db_version) self._db_version = db_version return db_version @@ -299,7 +299,7 @@ def db_version(self): def db_version(self, version): self.env['ir.config_parameter'].set_param( self._version_parameter_name, str(version)) - self._db_version = OpenERPVersion(version) + self._db_version = OdooVersion(version) @property def package_version(self): @@ -318,7 +318,7 @@ def package_version(self): line = line.split('#', 1)[0].strip() if not line: continue - self._pkg_version = OpenERPVersion(line) + self._pkg_version = OdooVersion(line) return self._pkg_version except IOError: logger.info("No version file could be read, " @@ -336,7 +336,7 @@ def init_cursor(self): if db is None: # current trunk (future v8) self.cr = self._registry.cursor() else: - # In OpenERP < 8, Registry.cursor() object is + # In Odoo < 8, Registry.cursor() object is # a context manager providing auto closing, # but we don't want to control the whole lifespan # of the cursor. @@ -356,7 +356,7 @@ def rollback(self): def is_cursor_closed(self): """Compatibility wrapper. - On OpenERP 7, the attribute is ``__closed`` but can't even be accessed + On Odoo 7, the attribute is ``__closed`` but can't even be accessed if the cursor is closed (``OperationalError`` is raised systematically in ``sql_db``) @@ -378,7 +378,7 @@ def close(self): self.cr.close() self.clean_environments() # GR: I did check that implementation is designed not to fail - # on Odoo 8 and OpenERP 7 + # on Odoo 8 and Odoo 7 odoo.modules.registry.RegistryManager.delete(dbname) def update_modules(self, modules, db=None): diff --git a/anybox/recipe/odoo/server.py b/anybox/recipe/odoo/server.py index 0058db95..9052c06c 100644 --- a/anybox/recipe/odoo/server.py +++ b/anybox/recipe/odoo/server.py @@ -23,15 +23,15 @@ class ServerRecipe(BaseRecipe): } nightly_filenames = { - '8.0': 'odoo_8.0.%s.tar.gz', - 'trunk': 'odoo_9.0alpha1.%s.tar.gz' + '10.0': 'odoo_10.0.%s.tar.gz', + 'trunk': 'odoo_10.0alpha1.%s.tar.gz' } """Name of expected nightly tarballs in base URL, by major version. """ recipe_requirements = ('babel',) requirements = ('anybox.recipe.odoo',) - soft_requirements = ('openerp-command',) + soft_requirements = ('odoo-command',) with_gunicorn = False with_upgrade = True ws = None @@ -48,7 +48,7 @@ def __init__(self, *a, **kw): # discarding, because we have a special behaviour with custom # interpreters opt.pop('interpreter', None) - self.openerp_scripts = {} + self.odoo_scripts = {} sw_modules = option_splitlines(opt.get('server_wide_modules')) if sw_modules and 'web' not in sw_modules: sw_modules = ('web', ) + sw_modules @@ -72,20 +72,20 @@ def apply_version_dependent_decisions(self): def merge_requirements(self, reqs=None): """Prepare for installation by zc.recipe.egg - - develop the openerp distribution and require it + - develop the odoo distribution and require it - gunicorn's related dependencies if needed - Once 'openerp' is required, zc.recipe.egg will take it into account + Once 'odoo' is required, zc.recipe.egg will take it into account and put it in needed scripts, interpreters etc. - Historically, in ``anybox.recipe.openerp`` this used to take care + Historically, in ``anybox.recipe.odoo`` this used to take care of adding Pillow, which is now in Odoo's ``setup.py``. """ - openerp_dir = getattr(self, 'openerp_dir', None) - openerp_project_name = 'openerp' - if openerp_dir is not None: # happens in unit tests - openerp_project_name = self.develop(openerp_dir) - self.requirements.append(openerp_project_name) + odoo_dir = getattr(self, 'odoo_dir', None) + odoo_project_name = 'odoo' + if odoo_dir is not None: # happens in unit tests + odoo_project_name = self.develop(odoo_dir) + self.requirements.append(odoo_project_name) if self.with_gunicorn: self.requirements.extend(('psutil', 'gunicorn')) @@ -94,13 +94,13 @@ def merge_requirements(self, reqs=None): self.requirements.extend(devtools.requirements) BaseRecipe.merge_requirements(self, reqs=reqs) - return openerp_project_name + return odoo_project_name def _create_default_config(self): """Have Odoo generate its default config file. """ self.options.setdefault('options.admin_passwd', '') - sys.path.append(self.openerp_dir) + sys.path.append(self.odoo_dir) sys.path.extend([egg.location for egg in self.ws]) from odoo.tools.config import configmanager configmanager(self.config_path).save() @@ -131,7 +131,7 @@ def _create_gunicorn_conf(self, qualified_name): f = open(join(self.etc, qualified_name + '.conf.py'), 'w') conf = """'''Gunicorn configuration script. Generated by buildout. Do NOT edit.''' -import openerp +import odoo bind = %(bind)r pidfile = %(qualified_name)r + '.pid' workers = %(workers)s @@ -139,9 +139,9 @@ def _create_gunicorn_conf(self, qualified_name): timeout = %(timeout)s max_requests = %(max_requests)s -openerp.multi_process = True # needed even with only one worker -openerp.conf.server_wide_modules = %(server_wide_modules)r -conf = openerp.tools.config +odoo.multi_process = True # needed even with only one worker +odoo.conf.server_wide_modules = %(server_wide_modules)r +conf = odoo.tools.config """ % gunicorn_options # forwarding specified options @@ -167,7 +167,7 @@ def _create_gunicorn_conf(self, qualified_name): "", "def post_fork(server, worker):", " '''Preload databases specified in buildout conf.'''", - " from openerp.modules.registry import RegistryManager", + " from odoo.modules.registry import RegistryManager", " preload_dbs = %r" % (preload_dbs,), " for db_name in preload_dbs:", " server.log.info('Worker loading database %r',", @@ -183,15 +183,15 @@ def _create_gunicorn_conf(self, qualified_name): def _get_server_command(self): """Return a full path to the main Odoo server command.""" - return join(self.openerp_dir, 'odoo-bin') + return join(self.odoo_dir, 'odoo-bin') - def _parse_openerp_scripts(self): + def _parse_odoo_scripts(self): """Parse required scripts from conf.""" - scripts = self.openerp_scripts - if 'openerp_scripts' not in self.options: + scripts = self.odoo_scripts + if 'odoo_scripts' not in self.options: return - for line in option_splitlines(self.options.get('openerp_scripts')): + for line in option_splitlines(self.options.get('odoo_scripts')): line = line.split() naming = line[0].split('=') @@ -207,7 +207,7 @@ def _parse_openerp_scripts(self): opt_prefix = 'command-line-options=' arg_prefix = 'arguments=' - log_prefix = 'openerp-log-level=' + log_prefix = 'odoo-log-level=' for token in line[1:]: if token.startswith(opt_prefix): cl_options.extend(token[len(opt_prefix):].split(',')) @@ -218,7 +218,7 @@ def _parse_openerp_scripts(self): if level not in dir(logging): raise UserError("In script %r, improper logging " "level %r" % (name, level)) - desc['openerp_log_level'] = level + desc['odoo_log_level'] = level else: raise UserError( "Invalid token for script %r: %r" % (name, token)) @@ -230,18 +230,18 @@ def _get_or_create_script(self, entry, name=None): None if not found. In all other cases, return return (script_name, desc). """ - for script_name, desc in self.openerp_scripts.iteritems(): + for script_name, desc in self.odoo_scripts.iteritems(): if desc['entry'] == entry: return script_name, desc if name is not None: - desc = self.openerp_scripts[name] = dict(entry=entry) + desc = self.odoo_scripts[name] = dict(entry=entry) return name, desc def _register_main_startup_script(self, qualified_name): """Register main startup script, usually ``start_openerp`` for install. """ - desc = self._get_or_create_script('openerp_starter', + desc = self._get_or_create_script('odoo_starter', name=qualified_name)[1] arguments = '%r, %r, version=%r, gevent_script_path=%r' % ( @@ -276,7 +276,7 @@ def _register_main_startup_script(self, qualified_name): def _register_test_script(self, qualified_name): """Register the main test script for installation. """ - desc = self._get_or_create_script('openerp_tester', + desc = self._get_or_create_script('odoo_tester', name=qualified_name)[1] arguments = '%r, %r, version=%r, just_test=True' % ( self._get_server_command(), @@ -285,7 +285,7 @@ def _register_test_script(self, qualified_name): arguments += ', gevent_script_path=%r' % self.gevent_script_path desc.update( - entry='openerp_starter', + entry='odoo_starter', initialization=os.linesep.join(( "from anybox.recipe.odoo import devtools", "devtools.load(for_tests=True)", @@ -294,7 +294,7 @@ def _register_test_script(self, qualified_name): ) def _register_upgrade_script(self, qualified_name): - desc = self._get_or_create_script('openerp_upgrader', + desc = self._get_or_create_script('odoo_upgrader', name=qualified_name)[1] script_opt = option_strip(self.options.get('upgrade_script', 'upgrade.py run')) @@ -306,7 +306,7 @@ def _register_upgrade_script(self, qualified_name): "SOURCE_FILE CALLABLE (got '%r')" % script)) script_source_path = self.make_absolute(script[0]) desc.update( - entry='openerp_upgrader', + entry='odoo_upgrader', arguments='%r, %r, %r, %r' % ( script_source_path, script[1], self.config_path, self.buildout_dir), @@ -334,7 +334,7 @@ def _register_gunicorn_startup_script(self, qualified_name): gunicorn_entry_point = gunicorn_options.get('entry_point') if gunicorn_entry_point is None: - gunicorn_entry_point = ('openerp:' + gunicorn_entry_point = ('odoo:' 'service.wsgi_server.application') # gunicorn's main() does not take arguments, that's why we have @@ -346,7 +346,7 @@ def _register_gunicorn_startup_script(self, qualified_name): def _register_gevent_script(self, qualified_name): """Register the gevent startup script """ - desc = self._get_or_create_script('openerp-gevent', + desc = self._get_or_create_script('odoo-gevent', name=qualified_name)[1] initialization = [ @@ -372,29 +372,29 @@ def _register_cron_worker_startup_script(self, qualified_name): These changes appeared in nightly build 6.1-20120530-233414. The worker script itself does not appear in nightly builds. """ - script_src = join(self.openerp_dir, 'openerp-cron-worker') + script_src = join(self.odoo_dir, 'odoo-cron-worker') if not os.path.isfile(script_src): version = self.version_detected if self.version_wanted == '6.1-1' or ( version.startswith('6.1-2012') and version[4:12] < '20120530'): logger.warn( - "Can't use openerp-cron-worker with version %s " + "Can't use odoo-cron-worker with version %s " "You have to run a separate regular Odoo process " "for cron jobs to be launched.", version) return - logger.info("Cron launcher openerp-cron-worker not found in " - "openerp source tree (version %s). " + logger.info("Cron launcher odoo-cron-worker not found in " + "odoo source tree (version %s). " "This is expected with some nightly builds. " "Using the launcher script distributed " "with the recipe.", version) script_src = join(os.path.split(__file__)[0], - 'openerp-cron-worker') + 'odoo-cron-worker') - desc = self._get_or_create_script('openerp_cron_worker', + desc = self._get_or_create_script('odoo_cron_worker', name=qualified_name)[1] - desc.update(entry='openerp_cron_worker', + desc.update(entry='odoo_cron_worker', arguments='%r, %r' % (script_src, self.config_path), initialization='', ) @@ -424,7 +424,7 @@ def _install_interpreter(self): " print('Then you can issue commands such as:')", " print(\"" " session.registry('res.users').browse(session.cr, 1, 1)\")", - " from openerp import release", + " from odoo import release", " from anybox.recipe.odoo.utils import major_version", " if major_version(release.version)[0] >= 8:", " print('Or using new api:')", @@ -443,8 +443,8 @@ def _install_interpreter(self): # relative_paths=self._relative_paths, ) - def _install_openerp_scripts(self): - """Install scripts registered in self.openerp_scripts. + def _install_odoo_scripts(self): + """Install scripts registered in self.odoo_scripts. If initialization string is not passed, one will be cooked for - session initialization @@ -461,14 +461,14 @@ def _install_openerp_scripts(self): self.buildout_dir), )) - for script_name, desc in self.openerp_scripts.items(): + for script_name, desc in self.odoo_scripts.items(): initialization = desc.get('initialization', common_init) - log_level = desc.get('openerp_log_level') + log_level = desc.get('odoo_log_level') if log_level: initialization = os.linesep.join(( initialization, "import logging", - "logging.getLogger('openerp').setLevel" + "logging.getLogger('odoo').setLevel" "(logging.%s)" % log_level)) options = desc.get('command_line_options') if options: @@ -486,25 +486,25 @@ def _install_openerp_scripts(self): extra_paths=self.extra_paths, # relative_paths=self._relative_paths, ) - self.openerp_installed.append(join(self.bin_dir, script_name)) + self.odoo_installed.append(join(self.bin_dir, script_name)) def _install_startup_scripts(self): """install startup and control scripts. """ - self._parse_openerp_scripts() + self._parse_odoo_scripts() # provide additional needed entry points for main start/test scripts self.eggs_reqs.extend(( - ('openerp_starter', + ('odoo_starter', 'anybox.recipe.odoo.runtime.start_openerp', 'main'), - ('openerp_cron_worker', + ('odoo_cron_worker', 'anybox.recipe.odoo.runtime.start_openerp', 'main'), - ('openerp-gevent', - 'openerp.cli', + ('odoo-gevent', + 'odoo.cli', 'main'), - ('openerp_upgrader', + ('odoo_upgrader', 'anybox.recipe.odoo.runtime.upgrade', 'upgrade'), )) @@ -539,4 +539,4 @@ def _install_startup_scripts(self): 'upgrade_%s' % self.name) self._register_upgrade_script(qualified_name) - self._install_openerp_scripts() + self._install_odoo_scripts() diff --git a/anybox/recipe/odoo/testing.py b/anybox/recipe/odoo/testing.py index fa4c45d3..e8a78d65 100644 --- a/anybox/recipe/odoo/testing.py +++ b/anybox/recipe/odoo/testing.py @@ -24,9 +24,9 @@ class TestingRecipe(BaseRecipe): """A subclass with just enough few defaults for unit testing.""" - release_filenames = {'8.0': 'blob-%s.tgz'} - nightly_filenames = {'8.0': '8-0-nightly-%s.tbz'} - release_dl_url = {'8.0': 'http://release.odoo.test/src/'} + release_filenames = {'10.0': 'blob-%s.tgz'} + nightly_filenames = {'10.0rc1c': '10-0-nightly-%s.tbz'} + release_dl_url = {'10.0': 'http://release.odoo.test/src/'} def __init__(self, buildout, name, options): # we need to make buildout a regular object, because some subsystems @@ -166,7 +166,7 @@ def _obtain(inst, requirement, source=None): return inst._orig_obtain(requirement, source=source) Installer._obtain = _obtain - def make_recipe(self, name='openerp', **options): + def make_recipe(self, name='odoo', **options): self.recipe = TestingRecipe(self.buildout, name, options) def tearDown(self): diff --git a/anybox/recipe/odoo/tests/integration_buildouts/buildout.cfg b/anybox/recipe/odoo/tests/integration_buildouts/buildout.cfg index 7121efd8..627139f7 100644 --- a/anybox/recipe/odoo/tests/integration_buildouts/buildout.cfg +++ b/anybox/recipe/odoo/tests/integration_buildouts/buildout.cfg @@ -9,6 +9,6 @@ develop-eggs-directory = ${buildout:directory}/develop-eggs [odoo] recipe = anybox.recipe.odoo:server -version = local odoo80 +version = local odoo10 apply-requirements-file = true eggs = foobar diff --git a/anybox/recipe/odoo/tests/integration_buildouts/buildout_with_versions.cfg b/anybox/recipe/odoo/tests/integration_buildouts/buildout_with_versions.cfg index d8cd7265..6e1b5ec9 100644 --- a/anybox/recipe/odoo/tests/integration_buildouts/buildout_with_versions.cfg +++ b/anybox/recipe/odoo/tests/integration_buildouts/buildout_with_versions.cfg @@ -9,7 +9,7 @@ develop-eggs-directory = ${buildout:directory}/develop-eggs [odoo] recipe = anybox.recipe.odoo:server -version = local odoo80 +version = local odoo10 apply-requirements-file = true eggs = foobar diff --git a/anybox/recipe/odoo/tests/integration_buildouts/odoo80/openerp-gevent b/anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo-bin similarity index 100% rename from anybox/recipe/odoo/tests/integration_buildouts/odoo80/openerp-gevent rename to anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo-bin diff --git a/anybox/recipe/odoo/tests/integration_buildouts/odoo80/openerp-server b/anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo-gevent similarity index 100% rename from anybox/recipe/odoo/tests/integration_buildouts/odoo80/openerp-server rename to anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo-gevent diff --git a/anybox/recipe/odoo/tests/integration_buildouts/odoo80/odoo.py b/anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo.py similarity index 100% rename from anybox/recipe/odoo/tests/integration_buildouts/odoo80/odoo.py rename to anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo.py diff --git a/anybox/recipe/odoo/tests/integration_buildouts/odoo80/openerp/__init__.py b/anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo/__init__.py similarity index 100% rename from anybox/recipe/odoo/tests/integration_buildouts/odoo80/openerp/__init__.py rename to anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo/__init__.py diff --git a/anybox/recipe/odoo/tests/odoo-project-renaming/openerp/release.py b/anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo/release.py similarity index 86% rename from anybox/recipe/odoo/tests/odoo-project-renaming/openerp/release.py rename to anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo/release.py index 2c05162c..b9fe525c 100644 --- a/anybox/recipe/odoo/tests/odoo-project-renaming/openerp/release.py +++ b/anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo/release.py @@ -2,8 +2,8 @@ # flake8: noqa ############################################################################## # -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-TODAY OpenERP S.A. +# Odoo, Open Source Management Solution +# Copyright (C) 2004-TODAY Odoo S.A. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -31,12 +31,12 @@ # properly comparable using normal operarors, for example: # (6,1,0,'beta',0) < (6,1,0,'candidate',1) < (6,1,0,'candidate',2) # (6,1,0,'candidate',2) < (6,1,0,'final',0) < (6,1,2,'final',0) -version_info = (8, 0, 0, ALPHA, 1) +version_info = (10, 0, 0, ALPHA, 1) version = '.'.join(map(str, version_info[:2])) + RELEASE_LEVELS_DISPLAY[version_info[3]] + str(version_info[4] or '') series = serie = major_version = '.'.join(map(str, version_info[:2])) -description = 'OpenERP Server' -long_desc = '''OpenERP is a complete ERP and CRM. The main features are accounting (analytic +description = 'Odoo Server' +long_desc = '''Odoo is a complete ERP and CRM. The main features are accounting (analytic and financial), stock management, sales and purchases management, tasks automation, marketing campaigns, help desk, POS, etc. Technical features include a distributed server, flexible workflows, an object database, a dynamic GUI, @@ -47,10 +47,10 @@ Programming Language :: Python """ url = 'http://www.openerp.com' -author = 'OpenERP S.A.' +author = 'Odoo S.A.' author_email = 'info@openerp.com' license = 'AGPL-3' -nt_service_name = "openerp-server-" + series +nt_service_name = "odoo-bin-" + series # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/anybox/recipe/odoo/tests/integration_buildouts/odoo80/openerp/tools/__init__.py b/anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo/tools/__init__.py similarity index 100% rename from anybox/recipe/odoo/tests/integration_buildouts/odoo80/openerp/tools/__init__.py rename to anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo/tools/__init__.py diff --git a/anybox/recipe/odoo/tests/integration_buildouts/odoo80/openerp/tools/config.py b/anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo/tools/config.py similarity index 100% rename from anybox/recipe/odoo/tests/integration_buildouts/odoo80/openerp/tools/config.py rename to anybox/recipe/odoo/tests/integration_buildouts/odoo10/odoo/tools/config.py diff --git a/anybox/recipe/odoo/tests/integration_buildouts/odoo80/requirements.txt b/anybox/recipe/odoo/tests/integration_buildouts/odoo10/requirements.txt similarity index 100% rename from anybox/recipe/odoo/tests/integration_buildouts/odoo80/requirements.txt rename to anybox/recipe/odoo/tests/integration_buildouts/odoo10/requirements.txt diff --git a/anybox/recipe/odoo/tests/odoo80/setup.py b/anybox/recipe/odoo/tests/integration_buildouts/odoo10/setup.py similarity index 93% rename from anybox/recipe/odoo/tests/odoo80/setup.py rename to anybox/recipe/odoo/tests/integration_buildouts/odoo10/setup.py index 316e93a9..0d8dd5e1 100644 --- a/anybox/recipe/odoo/tests/odoo80/setup.py +++ b/anybox/recipe/odoo/tests/integration_buildouts/odoo10/setup.py @@ -29,7 +29,7 @@ # List all data files def data(): r = {} - for root, dirnames, filenames in os.walk('openerp'): + for root, dirnames, filenames in os.walk('odoo'): for filename in filenames: if not re.match(r'.*(\.pyc|\.pyo|\~)$', filename): r.setdefault(root, []).append(os.path.join(root, filename)) @@ -73,8 +73,8 @@ def py2exe_options(): if os.name == 'nt': import py2exe return { - "console" : [ { "script": "openerp-server", "icon_resources": [(1, join("install","openerp-icon.ico"))], }, - { "script": "openerp-gevent" }, + "console" : [ { "script": "odoo-bin", "icon_resources": [(1, join("install","odoo-icon.ico"))], }, + { "script": "odoo-gevent" }, { "script": "odoo.py" }, ], 'options' : { @@ -98,7 +98,7 @@ def py2exe_options(): "mako", "markupsafe", # dependence of jinja2 and mako "mock", - "openerp", + "odoo", "poplib", "psutil", "pychart", @@ -125,7 +125,7 @@ def py2exe_options(): else: return {} -execfile(join(os.path.dirname(__file__), 'openerp', 'release.py')) +execfile(join(os.path.dirname(__file__), 'odoo', 'release.py')) # Notes for OpenERP developer on windows: # @@ -141,7 +141,7 @@ def py2exe_options(): # Both python2.7 32bits and 64bits are known to work. setuptools.setup( - name = 'openerp', + name = 'odoo', version = version, description = description, long_description = long_desc, @@ -150,7 +150,7 @@ def py2exe_options(): author_email = author_email, classifiers = filter(None, classifiers.split("\n")), license = license, - scripts = ['openerp-server', 'openerp-gevent', 'odoo.py'], + scripts = ['odoo-bin', 'odoo-gevent', 'odoo.py'], data_files = data(), packages = setuptools.find_packages(), #include_package_data = True, diff --git a/anybox/recipe/odoo/tests/integration_buildouts/odoo80/setup.py b/anybox/recipe/odoo/tests/integration_buildouts/odoo80/setup.py deleted file mode 100644 index d813e345..00000000 --- a/anybox/recipe/odoo/tests/integration_buildouts/odoo80/setup.py +++ /dev/null @@ -1,75 +0,0 @@ -# -*- coding: utf-8 -*- -# flake8: noqa - -# setup.py from odoo 8.0 alpha, included as is, except for the dependencies - -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -import glob, os, re, setuptools, sys -from os.path import join - -# List all data files -def data(): - return [] - -def gen_manifest(): - file_list="\n".join(data()) - open('MANIFEST','w').write(file_list) - -execfile(join(os.path.dirname(__file__), 'openerp', 'release.py')) - -# Notes for OpenERP developer on windows: -# -# To setup a windows developer evironement install python2.7 then pip and use -# "pip install " for every dependency listed below. -# -# Dependecies that requires DLLs are not installable with pip install, for -# them we added comments with links where you can find the installers. -# -# OpenERP on windows also require the pywin32, the binary can be found at -# http://pywin32.sf.net -# -# Both python2.7 32bits and 64bits are known to work. - -setuptools.setup( - name = 'openerp', - version = version, - description = description, - long_description = long_desc, - url = url, - author = author, - author_email = author_email, - classifiers = filter(None, classifiers.split("\n")), - license = license, - scripts = ['openerp-server', 'openerp-gevent', 'odoo.py'], - data_files = data(), - packages = setuptools.find_packages(), - dependency_links = [], - #include_package_data = True, - # GR voided the list, because we're interested in the test in what - # the recipe will add - install_requires = [], - extras_require = {}, - tests_require = [], -) - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/anybox/recipe/odoo/tests/odoo-project-renaming/openerp-gevent b/anybox/recipe/odoo/tests/odoo-project-renaming/odoo-bin similarity index 100% rename from anybox/recipe/odoo/tests/odoo-project-renaming/openerp-gevent rename to anybox/recipe/odoo/tests/odoo-project-renaming/odoo-bin diff --git a/anybox/recipe/odoo/tests/odoo-project-renaming/openerp-server b/anybox/recipe/odoo/tests/odoo-project-renaming/odoo-gevent similarity index 100% rename from anybox/recipe/odoo/tests/odoo-project-renaming/openerp-server rename to anybox/recipe/odoo/tests/odoo-project-renaming/odoo-gevent diff --git a/anybox/recipe/odoo/tests/odoo-project-renaming/openerp/__init__.py b/anybox/recipe/odoo/tests/odoo-project-renaming/odoo/__init__.py similarity index 100% rename from anybox/recipe/odoo/tests/odoo-project-renaming/openerp/__init__.py rename to anybox/recipe/odoo/tests/odoo-project-renaming/odoo/__init__.py diff --git a/anybox/recipe/odoo/tests/integration_buildouts/odoo80/openerp/release.py b/anybox/recipe/odoo/tests/odoo-project-renaming/odoo/release.py similarity index 96% rename from anybox/recipe/odoo/tests/integration_buildouts/odoo80/openerp/release.py rename to anybox/recipe/odoo/tests/odoo-project-renaming/odoo/release.py index 2c05162c..6568c410 100644 --- a/anybox/recipe/odoo/tests/integration_buildouts/odoo80/openerp/release.py +++ b/anybox/recipe/odoo/tests/odoo-project-renaming/odoo/release.py @@ -31,7 +31,7 @@ # properly comparable using normal operarors, for example: # (6,1,0,'beta',0) < (6,1,0,'candidate',1) < (6,1,0,'candidate',2) # (6,1,0,'candidate',2) < (6,1,0,'final',0) < (6,1,2,'final',0) -version_info = (8, 0, 0, ALPHA, 1) +version_info = (10, 0, 0, ALPHA, 1) version = '.'.join(map(str, version_info[:2])) + RELEASE_LEVELS_DISPLAY[version_info[3]] + str(version_info[4] or '') series = serie = major_version = '.'.join(map(str, version_info[:2])) @@ -51,6 +51,6 @@ author_email = 'info@openerp.com' license = 'AGPL-3' -nt_service_name = "openerp-server-" + series +nt_service_name = "odoo-bin-" + series # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/anybox/recipe/odoo/tests/odoo-project-renaming/setup.py b/anybox/recipe/odoo/tests/odoo-project-renaming/setup.py index d1cc27d2..26a97ac7 100644 --- a/anybox/recipe/odoo/tests/odoo-project-renaming/setup.py +++ b/anybox/recipe/odoo/tests/odoo-project-renaming/setup.py @@ -29,7 +29,7 @@ # List all data files def data(): r = {} - for root, dirnames, filenames in os.walk('openerp'): + for root, dirnames, filenames in os.walk('odoo'): for filename in filenames: if not re.match(r'.*(\.pyc|\.pyo|\~)$', filename): r.setdefault(root, []).append(os.path.join(root, filename)) @@ -73,8 +73,8 @@ def py2exe_options(): if os.name == 'nt': import py2exe return { - "console" : [ { "script": "openerp-server", "icon_resources": [(1, join("install","openerp-icon.ico"))], }, - { "script": "openerp-gevent" }, + "console" : [ { "script": "odoo-bin", "icon_resources": [(1, join("install","odoo-icon.ico"))], }, + { "script": "odoo-gevent" }, { "script": "odoo.py" }, ], 'options' : { @@ -98,7 +98,7 @@ def py2exe_options(): "mako", "markupsafe", # dependence of jinja2 and mako "mock", - "openerp", + "odoo", "poplib", "psutil", "pychart", @@ -125,7 +125,7 @@ def py2exe_options(): else: return {} -execfile(join(os.path.dirname(__file__), 'openerp', 'release.py')) +execfile(join(os.path.dirname(__file__), 'odoo', 'release.py')) # Notes for OpenERP developer on windows: # @@ -141,7 +141,7 @@ def py2exe_options(): # Both python2.7 32bits and 64bits are known to work. setuptools.setup( - name = 'oodooo', + name = 'odoo', version = version, description = description, long_description = long_desc, @@ -150,7 +150,7 @@ def py2exe_options(): author_email = author_email, classifiers = filter(None, classifiers.split("\n")), license = license, - scripts = ['openerp-server', 'openerp-gevent', 'odoo.py'], + scripts = ['odoo-bin', 'odoo-gevent', 'odoo.py'], data_files = data(), packages = setuptools.find_packages(), #include_package_data = True, diff --git a/anybox/recipe/odoo/tests/odoo80/openerp-gevent b/anybox/recipe/odoo/tests/odoo10/odoo-bin similarity index 100% rename from anybox/recipe/odoo/tests/odoo80/openerp-gevent rename to anybox/recipe/odoo/tests/odoo10/odoo-bin diff --git a/anybox/recipe/odoo/tests/odoo80/openerp-server b/anybox/recipe/odoo/tests/odoo10/odoo-gevent similarity index 100% rename from anybox/recipe/odoo/tests/odoo80/openerp-server rename to anybox/recipe/odoo/tests/odoo10/odoo-gevent diff --git a/anybox/recipe/odoo/tests/odoo80/odoo.py b/anybox/recipe/odoo/tests/odoo10/odoo.py similarity index 100% rename from anybox/recipe/odoo/tests/odoo80/odoo.py rename to anybox/recipe/odoo/tests/odoo10/odoo.py diff --git a/anybox/recipe/odoo/tests/odoo80/openerp/__init__.py b/anybox/recipe/odoo/tests/odoo10/odoo/__init__.py similarity index 100% rename from anybox/recipe/odoo/tests/odoo80/openerp/__init__.py rename to anybox/recipe/odoo/tests/odoo10/odoo/__init__.py diff --git a/anybox/recipe/odoo/tests/odoo80/openerp/release.py b/anybox/recipe/odoo/tests/odoo10/odoo/release.py similarity index 86% rename from anybox/recipe/odoo/tests/odoo80/openerp/release.py rename to anybox/recipe/odoo/tests/odoo10/odoo/release.py index 2c05162c..b9fe525c 100644 --- a/anybox/recipe/odoo/tests/odoo80/openerp/release.py +++ b/anybox/recipe/odoo/tests/odoo10/odoo/release.py @@ -2,8 +2,8 @@ # flake8: noqa ############################################################################## # -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-TODAY OpenERP S.A. +# Odoo, Open Source Management Solution +# Copyright (C) 2004-TODAY Odoo S.A. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -31,12 +31,12 @@ # properly comparable using normal operarors, for example: # (6,1,0,'beta',0) < (6,1,0,'candidate',1) < (6,1,0,'candidate',2) # (6,1,0,'candidate',2) < (6,1,0,'final',0) < (6,1,2,'final',0) -version_info = (8, 0, 0, ALPHA, 1) +version_info = (10, 0, 0, ALPHA, 1) version = '.'.join(map(str, version_info[:2])) + RELEASE_LEVELS_DISPLAY[version_info[3]] + str(version_info[4] or '') series = serie = major_version = '.'.join(map(str, version_info[:2])) -description = 'OpenERP Server' -long_desc = '''OpenERP is a complete ERP and CRM. The main features are accounting (analytic +description = 'Odoo Server' +long_desc = '''Odoo is a complete ERP and CRM. The main features are accounting (analytic and financial), stock management, sales and purchases management, tasks automation, marketing campaigns, help desk, POS, etc. Technical features include a distributed server, flexible workflows, an object database, a dynamic GUI, @@ -47,10 +47,10 @@ Programming Language :: Python """ url = 'http://www.openerp.com' -author = 'OpenERP S.A.' +author = 'Odoo S.A.' author_email = 'info@openerp.com' license = 'AGPL-3' -nt_service_name = "openerp-server-" + series +nt_service_name = "odoo-bin-" + series # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/anybox/recipe/odoo/tests/odoo10/setup.py b/anybox/recipe/odoo/tests/odoo10/setup.py new file mode 100644 index 00000000..9db582dd --- /dev/null +++ b/anybox/recipe/odoo/tests/odoo10/setup.py @@ -0,0 +1,167 @@ +# -*- coding: utf-8 -*- +# flake8: noqa + +# setup.py from odoo 10.0 alpha, included as is, except for the dependencies + +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import glob, os, re, setuptools, sys +from os.path import join + +# List all data files +def data(): + r = {} + for root, dirnames, filenames in os.walk('odoo'): + for filename in filenames: + if not re.match(r'.*(\.pyc|\.pyo|\~)$', filename): + r.setdefault(root, []).append(os.path.join(root, filename)) + + if os.name == 'nt': + r["Microsoft.VC90.CRT"] = glob.glob('C:\Microsoft.VC90.CRT\*.*') + + import babel + # Add data, but also some .py files py2exe won't include automatically. + # TODO This should probably go under `packages`, instead of `data`, + # but this will work fine (especially since we don't use the ZIP file + # approach). + r["babel/localedata"] = glob.glob(os.path.join(os.path.dirname(babel.__file__), "localedata", '*')) + others = ['global.dat', 'numbers.py', 'support.py', 'plural.py'] + r["babel"] = map(lambda f: os.path.join(os.path.dirname(babel.__file__), f), others) + others = ['frontend.py', 'mofile.py'] + r["babel/messages"] = map(lambda f: os.path.join(os.path.dirname(babel.__file__), "messages", f), others) + + import pytz + tzdir = os.path.dirname(pytz.__file__) + for root, _, filenames in os.walk(os.path.join(tzdir, "zoneinfo")): + base = os.path.join('pytz', root[len(tzdir) + 1:]) + r[base] = [os.path.join(root, f) for f in filenames] + + import docutils + dudir = os.path.dirname(docutils.__file__) + for root, _, filenames in os.walk(dudir): + base = os.path.join('docutils', root[len(dudir) + 1:]) + r[base] = [os.path.join(root, f) for f in filenames if not f.endswith(('.py', '.pyc', '.pyo'))] + + return r.items() + +def gen_manifest(): + file_list="\n".join(data()) + open('MANIFEST','w').write(file_list) + +if os.name == 'nt': + sys.path.append("C:\Microsoft.VC90.CRT") + +def py2exe_options(): + if os.name == 'nt': + import py2exe + return { + "console" : [ { "script": "odoo-bin", "icon_resources": [(1, join("install","odoo-icon.ico"))], }, + { "script": "odoo-gevent" }, + { "script": "odoo.py" }, + ], + 'options' : { + "py2exe": { + "skip_archive": 1, + "optimize": 0, # keep the assert running, because the integrated tests rely on them. + "dist_dir": 'dist', + "packages": [ + "HTMLParser", + "PIL", + "asynchat", "asyncore", + "commands", + "dateutil", + "decimal", + "docutils", + "email", + "encodings", + "imaplib", + "jinja2", + "lxml", "lxml._elementpath", "lxml.builder", "lxml.etree", "lxml.objectify", + "mako", + "markupsafe", # dependence of jinja2 and mako + "mock", + "odoo", + "poplib", + "psutil", + "pychart", + "pydot", + "pyparsing", + "pytz", + "reportlab", + "requests", + "select", + "simplejson", + "smtplib", + "uuid", + "vatnumber", + "vobject", + "win32service", "win32serviceutil", + "xlwt", + "xml", "xml.dom", + "yaml", + ], + "excludes" : ["Tkconstants","Tkinter","tcl"], + } + } + } + else: + return {} + +execfile(join(os.path.dirname(__file__), 'odoo', 'release.py')) + +# Notes for OpenERP developer on windows: +# +# To setup a windows developer evironement install python2.7 then pip and use +# "pip install " for every dependency listed below. +# +# Dependecies that requires DLLs are not installable with pip install, for +# them we added comments with links where you can find the installers. +# +# OpenERP on windows also require the pywin32, the binary can be found at +# http://pywin32.sf.net +# +# Both python2.7 32bits and 64bits are known to work. + +setuptools.setup( + name = 'odoo', + version = version, + description = description, + long_description = long_desc, + url = url, + author = author, + author_email = author_email, + classifiers = filter(None, classifiers.split("\n")), + license = license, + scripts = ['odoo-bin', 'odoo-gevent', 'odoo.py'], + data_files = data(), + packages = setuptools.find_packages(), + dependency_links = ['http://download.gna.org/pychart/'], + #include_package_data = True, + # GR voided the list, because we're interested in the test in what + # the recipe will add + install_requires = [], + extras_require = {}, + tests_require = [], + **py2exe_options() +) + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/anybox/recipe/odoo/tests/test_base.py b/anybox/recipe/odoo/tests/test_base.py index a849add2..65304f62 100644 --- a/anybox/recipe/odoo/tests/test_base.py +++ b/anybox/recipe/odoo/tests/test_base.py @@ -15,9 +15,9 @@ class TestingRecipe(BaseRecipe): """A subclass with just enough few defaults for unit testing.""" - release_filenames = {'8.0': 'blob-%s.tgz'} - nightly_filenames = {'8.0': '8-0-nightly-%s.tbz'} - release_dl_url = {'8.0': 'http://release.odoo.test/src/'} + release_filenames = {'10.0': 'blob-%s.tgz'} + nightly_filenames = {'10.0rc1c': '10.0%s.tar.gz'} + release_dl_url = {'10.0': 'http://release.odoo.test/src/'} class TestBaseRecipe(RecipeTestCase): @@ -38,68 +38,55 @@ def assertDownloadUrl(self, url): self.assertEquals(source[0], 'downloadable') self.assertEquals(source[1], url) - def test_version_release_8_0(self): - self.make_recipe(version='8.0-1') + def test_version_release_10_0(self): + self.make_recipe(version='10.0') recipe = self.recipe - self.assertEquals(recipe.version_wanted, '8.0-1') - self.assertDownloadUrl('http://release.odoo.test/src/blob-8.0-1.tgz') + self.assertEquals(recipe.version_wanted, '10.0') + self.assertDownloadUrl('http://release.odoo.test/src/blob-10.0.tgz') - def test_version_nightly_8_0(self): - self.make_recipe(version='nightly 8.0 1234-5') + def test_version_nightly_10_0(self): + self.make_recipe(version='nightly 10.0rc1c latest') self.assertDownloadUrl( - 'http://nightly.odoo.com/8.0/nightly/src/' - '8-0-nightly-1234-5.tbz') + 'http://nightly.odoo.com/10.0/nightly/src/10-0-nightly-latest.tbz') - def test_version_bzr_8_0(self): - # this one is a bit ridiculous now, but let's keep it - # and make a Git one beside it - self.make_recipe( - version='bzr lp:openobject-server/8.0 openerp-8.0 last:1') - - recipe = self.recipe - self.assertEquals(self.get_source_type(), 'bzr') - self.assertEquals(self.get_source_url(), - ('lp:openobject-server/8.0', 'last:1')) - self.assertEquals(recipe.openerp_dir, - os.path.join(recipe.parts, 'openerp-8.0')) def test_version_local(self): local_path = 'path/to/local/version' self.make_recipe(version='local ' + local_path) recipe = self.recipe self.assertEquals(self.get_source_type(), 'local') - self.assertTrue(recipe.openerp_dir.endswith(local_path)) + self.assertTrue(recipe.odoo_dir.endswith(local_path)) def test_version_url(self): - url = 'http://download.example/future/openerp-12.0.tgz' + url = 'http://download.example/future/odoo-12.0.tgz' self.make_recipe(version='url ' + url) recipe = self.recipe self.assertDownloadUrl(url) - self.assertEquals(recipe.archive_filename, 'openerp-12.0.tgz') + self.assertEquals(recipe.archive_filename, 'odoo-12.0.tgz') def test_base_url(self): - self.make_recipe(version='8.0-1', - base_url='http://example.org/openerp') - self.assertDownloadUrl('http://example.org/openerp/blob-8.0-1.tgz') + self.make_recipe(version='10.0-1', + base_url='http://example.org/odoo') + self.assertDownloadUrl('http://example.org/odoo/blob-10.0-1.tgz') def test_base_url_nightly(self): - self.make_recipe(version='nightly 8.0 1234-5', - base_url='http://example.org/openerp') + self.make_recipe(version='nightly 10.0rc1c latest', + base_url='http://example.org/odoo') self.assertDownloadUrl( - 'http://example.org/openerp/8-0-nightly-1234-5.tbz') + 'http://example.org/odoo/10-0-nightly-latest.tbz') def test_buildout_cfg_name(self): - self.make_recipe(version='8.0-1') + self.make_recipe(version='10.0-1') bcn = self.recipe.buildout_cfg_name self.assertEquals(bcn(), 'buildout.cfg') - self.assertEquals(bcn(('-D', 'install', 'openerp')), 'buildout.cfg') - self.assertEquals(bcn(('-c', '8.0.cfg')), '8.0.cfg') - self.assertEquals(bcn(('--config', '8.0.cfg')), '8.0.cfg') - self.assertEquals(bcn(('-o', '--config', '8.0.cfg')), '8.0.cfg') - self.assertEquals(bcn(('--config=8.0.cfg',)), '8.0.cfg') - self.assertEquals(bcn(('--config=8.0.cfg', '-o')), '8.0.cfg') + self.assertEquals(bcn(('-D', 'install', 'odoo')), 'buildout.cfg') + self.assertEquals(bcn(('-c', '10.0.cfg')), '10.0.cfg') + self.assertEquals(bcn(('--config', '10.0.cfg')), '10.0.cfg') + self.assertEquals(bcn(('-o', '--config', '10.0.cfg')), '10.0.cfg') + self.assertEquals(bcn(('--config=10.0.cfg',)), '10.0.cfg') + self.assertEquals(bcn(('--config=10.0.cfg', '-o')), '10.0.cfg') def test_parse_addons_revisions(self): """Test both parse_addons and parse_revisions.""" @@ -139,9 +126,9 @@ def test_parse_addons_illformed(self): # bad option 'hg http://some/repo addons-specific default opt:spam', # attempt to comment a line - """bzr lp:openerp-web web last:1 subdir=addons - bzr lp:openobject-addons openerp-addons last:1 - # bzr lp:openerp-something/8.0 addons-something last:1""", + """bzr lp:odoo-web web last:1 subdir=addons + bzr lp:openobject-addons odoo-addons last:1 + # bzr lp:odoo-something/10.0 addons-something last:1""", ): self.assertRaises(UserError, recipe.parse_addons, dict(addons=illformed)) @@ -258,10 +245,10 @@ def notimp_revert(self, rev): def test_finalize_addons_paths_git_layout(self): self.make_recipe( - version='git http://github.com/odoo/odoo.git odoo 7.0') - self.recipe.version_detected = '7.0-somerev' - oerp_dir = self.recipe.openerp_dir - base_addons = os.path.join(oerp_dir, 'openerp', 'addons') + version='git http://github.com/odoo/odoo.git odoo 10.0') + self.recipe.version_detected = '10.0-somerev' + oerp_dir = self.recipe.odoo_dir + base_addons = os.path.join(oerp_dir, 'odoo', 'addons') odoo_addons = os.path.join(oerp_dir, 'addons') os.makedirs(base_addons) os.makedirs(odoo_addons) @@ -272,10 +259,10 @@ def test_finalize_addons_paths_git_layout(self): def test_finalize_addons_paths_bzr_layout(self): self.make_recipe( - version='bzr lp:openobject-server openerp last:1') - self.recipe.version_detected = '7.0-somerev' - oerp_dir = self.recipe.openerp_dir - base_addons = os.path.join(oerp_dir, 'openerp', 'addons') + version='bzr lp:openobject-server odoo last:1') + self.recipe.version_detected = '10.0-somerev' + oerp_dir = self.recipe.odoo_dir + base_addons = os.path.join(oerp_dir, 'odoo', 'addons') os.makedirs(base_addons) self.recipe.addons_paths = ['/some/separate/addons'] self.recipe.finalize_addons_paths(check_existence=False) @@ -288,10 +275,10 @@ def test_finalize_addons_paths_order(self): set as local """ self.make_recipe( - version='git http://github.com/odoo/odoo.git odoo 7.0') - self.recipe.version_detected = '7.0-somerev' - oerp_dir = self.recipe.openerp_dir - base_addons = os.path.join(oerp_dir, 'openerp', 'addons') + version='git http://github.com/odoo/odoo.git odoo 10.0') + self.recipe.version_detected = '10.0-somerev' + oerp_dir = self.recipe.odoo_dir + base_addons = os.path.join(oerp_dir, 'odoo', 'addons') odoo_addons = os.path.join(oerp_dir, 'addons') os.makedirs(base_addons) os.makedirs(odoo_addons) @@ -309,15 +296,15 @@ def make_recipe_appplying_requirements_file(self, reqs_content): opts = {} opts[WITH_ODOO_REQUIREMENTS_FILE_OPTION] = 'true' self.make_recipe( - version='git http://github.com/odoo/odoo.git odoo 7.0', **opts) + version='git http://github.com/odoo/odoo.git odoo 10.0', **opts) - self.recipe.version_detected = '8.0-somerev' - oerp_dir = self.recipe.openerp_dir + self.recipe.version_detected = '10.0-somerev' + oerp_dir = self.recipe.odoo_dir os.makedirs(oerp_dir) if reqs_content is None: return - with open(os.path.join(self.recipe.openerp_dir, + with open(os.path.join(self.recipe.odoo_dir, 'requirements.txt'), 'w') as f: f.write(reqs_content + '\n') @@ -389,7 +376,7 @@ def test_apply_requirements_file_precedence1(self): def test_list_develops(self): self.make_recipe( - version='git http://github.com/odoo/odoo.git odoo 7.0') + version='git http://github.com/odoo/odoo.git odoo 10.0') self.assertEqual(self.recipe.list_develops(), []) self.develop_fictive() self.assertEqual(self.recipe.list_develops(), diff --git a/anybox/recipe/odoo/tests/test_extract.py b/anybox/recipe/odoo/tests/test_extract.py index 74f8a73d..7e42afbb 100644 --- a/anybox/recipe/odoo/tests/test_extract.py +++ b/anybox/recipe/odoo/tests/test_extract.py @@ -20,11 +20,11 @@ def tearDown(self): super(TestExtraction, self).tearDown() def make_recipe(self, **kwargs): - kwargs.setdefault('recipe', 'anybox.recipe.openerp:testrecipe') + kwargs.setdefault('recipe', 'anybox.recipe.odoo:testrecipe') super(TestExtraction, self).make_recipe(**kwargs) def test_prepare_extracted_buildout(self): - self.make_recipe(version='8.0') + self.make_recipe(version='10.0') conf = ConfigParser() self.recipe._prepare_extracted_buildout(conf, self.extract_target_dir) self.assertTrue('buildout' in conf.sections()) @@ -41,14 +41,14 @@ def test_extract_addons(self): conf = ConfigParser() extracted = set() self.recipe._extract_sources(conf, target_dir, extracted) - addons_opt = set(conf.get('openerp', 'addons').split(os.linesep)) + addons_opt = set(conf.get('odoo', 'addons').split(os.linesep)) self.assertEquals(addons_opt, set(('local vcs-addons', 'local specific'))) self.assertEquals(extracted, set([os.path.join(target_dir, 'vcs-addons')])) # no need to override revisions - self.assertRaises(NoOptionError, conf.get, 'openerp', 'revisions') + self.assertRaises(NoOptionError, conf.get, 'odoo', 'revisions') # testing that archival took place for fakevcs, but not for local @@ -77,10 +77,10 @@ def test_extract_addons_revisions(self): conf = ConfigParser() extracted = set() self.recipe._extract_sources(conf, target_dir, extracted) - self.assertEquals(conf.get('openerp', 'revisions').strip(), '') + self.assertEquals(conf.get('odoo', 'revisions').strip(), '') def test_prepare_extracted_buildout_gp_vcsdevelop(self): - self.make_recipe(version='8.0') + self.make_recipe(version='10.0') self.recipe.b_options[GP_VCS_EXTEND_DEVELOP] = ( "fakevcs+http://example.com/aeroolib#egg=aeroolib") self.recipe.b_options['develop'] = os.path.join( @@ -103,7 +103,7 @@ def test_prepare_extracted_buildout_gp_vcsdevelop(self): self.assertEquals(f.read(), 'fakerev') def test_prepare_extracted_buildout_gp_vcsdevelop_develop_dir(self): - self.make_recipe(version='8.0') + self.make_recipe(version='10.0') self.recipe.b_options[GP_VCS_EXTEND_DEVELOP] = ( "fakevcs+http://example.com/aeroolib#egg=aeroolib") self.recipe.b_options[GP_DEVELOP_DIR] = 'src' @@ -168,7 +168,7 @@ def test_extract_downloads_to(self): "pr_fakevcs http://repo2.example stdln2 rev2 group=stdl" ) os.mkdir(self.recipe.parts) - os.mkdir(os.path.join(self.recipe.openerp_dir)) + os.mkdir(os.path.join(self.recipe.odoo_dir)) self.recipe.retrieve_main_software() self.recipe.retrieve_addons() self.fill_working_set(fictive=True) @@ -178,11 +178,11 @@ def test_extract_downloads_to(self): ext_conf.read(os.path.join(self.extract_target_dir, 'release.cfg')) # notice standalone handling : - self.assertEqual(ext_conf.get('openerp', 'addons').splitlines(), + self.assertEqual(ext_conf.get('odoo', 'addons').splitlines(), ['local target', 'local somwehere', 'local stdl']) - self.assertEqual(ext_conf.get('openerp', 'version').strip(), + self.assertEqual(ext_conf.get('odoo', 'version').strip(), 'local parts/odooo') self.assertEqual(ext_conf.get('versions', self.fictive_name), self.fictive_version) diff --git a/anybox/recipe/odoo/tests/test_freeze.py b/anybox/recipe/odoo/tests/test_freeze.py index 093423ef..36ef3da6 100644 --- a/anybox/recipe/odoo/tests/test_freeze.py +++ b/anybox/recipe/odoo/tests/test_freeze.py @@ -17,7 +17,7 @@ def test_freeze_egg_versions(self): """ conf = ConfigParser() conf.add_section('freeze') - self.make_recipe(version='8.0') + self.make_recipe(version='10.0') self.fill_working_set(fictive=True) self.recipe._freeze_egg_versions(conf, 'freeze') try: @@ -35,7 +35,7 @@ def test_freeze_egg_versions_merge(self): conf = ConfigParser() conf.add_section('freeze') conf.set('freeze', 'some.distribution', '1.0alpha') - self.make_recipe(version='8.0') + self.make_recipe(version='10.0') self.fill_working_set(fictive=True) self.recipe._freeze_egg_versions(conf, 'freeze') try: @@ -49,14 +49,14 @@ def test_freeze_egg_versions_develop(self): """ conf = ConfigParser() conf.add_section('freeze') - self.make_recipe(version='8.0') + self.make_recipe(version='10.0') self.develop_fictive(require_install=True) self.recipe._freeze_egg_versions(conf, 'freeze') self.assertRaises(NoOptionError, conf.get, 'freeze', self.fictive_dist_name) def test_freeze_vcs_source(self): - self.make_recipe(version='8.0') + self.make_recipe(version='10.0') b_dir = self.recipe.buildout_dir repo_path = os.path.join(b_dir, 'custom') subprocess.check_call(['hg', 'init', repo_path]) @@ -77,7 +77,7 @@ def test_freeze_vcs_source(self): self.assertEquals(out, '', 'Extracted revision shows some diff') def test_freeze_vcs_source_already_frozen(self): - self.make_recipe(version='8.0') + self.make_recipe(version='10.0') b_dir = self.recipe.buildout_dir repo_path = os.path.join(b_dir, 'custom') subprocess.check_call(['hg', 'init', repo_path]) @@ -100,7 +100,7 @@ def test_freeze_vcs_source_already_frozen(self): 'default') def test_freeze_vcs_source_dirty(self): - self.make_recipe(version='8.0') + self.make_recipe(version='10.0') b_dir = self.recipe.buildout_dir repo_path = os.path.join(b_dir, 'custom') subprocess.check_call(['hg', 'init', repo_path]) @@ -129,13 +129,13 @@ def test_freeze_vcs_source_dirty(self): self.assertTrue(bool(self.recipe.local_modifications)) def test_prepare_frozen_buildout(self): - self.make_recipe(version='8.0') + self.make_recipe(version='10.0') conf = ConfigParser() self.recipe._prepare_frozen_buildout(conf) self.assertTrue('buildout' in conf.sections()) def test_prepare_frozen_buildout_gp_vcsdevelop(self): - self.make_recipe(version='8.0') + self.make_recipe(version='10.0') self.recipe.b_options[GP_VCS_EXTEND_DEVELOP] = ( "fakevcs+http://example.com/aeroolib#egg=aeroolib") @@ -154,7 +154,7 @@ def test_prepare_frozen_buildout_gp_vcsdevelop_already_fixed(self): manually updating the repo. In all cases, the instrospected revision will be used. """ - self.make_recipe(version='8.0') + self.make_recipe(version='10.0') self.recipe.b_options[GP_VCS_EXTEND_DEVELOP] = ( "fakevcs+http://example.com/aeroolib@somerev#egg=aeroolib") @@ -175,7 +175,7 @@ def test_freeze_to(self): "pr_fakevcs http://repo2.example stdln rev2 group=stdl" ) os.mkdir(self.recipe.parts) - os.mkdir(os.path.join(self.recipe.openerp_dir)) + os.mkdir(os.path.join(self.recipe.odoo_dir)) self.recipe.retrieve_main_software() self.recipe.retrieve_addons() self.fill_working_set(babel=True) @@ -191,5 +191,5 @@ def test_freeze_to(self): # the key in the addons sources for the standalone one has been # shifted, that's just what the group option does internally - self.assertEqual(outconf.get('openerp', 'revisions').splitlines(), + self.assertEqual(outconf.get('odoo', 'revisions').splitlines(), ['refspec', 'target rev1', 'stdl/stdln rev2']) diff --git a/anybox/recipe/odoo/tests/test_integration_server.py b/anybox/recipe/odoo/tests/test_integration_server.py index 6a4a43aa..b85746d6 100644 --- a/anybox/recipe/odoo/tests/test_integration_server.py +++ b/anybox/recipe/odoo/tests/test_integration_server.py @@ -1,7 +1,7 @@ """Full zc.buildout oriented integration tests. These are "whole loop" tests with respect to zc.buildout, but not at all with -respect to Odoo. For the latter, check the ``tests_with_openerp`` top directory +respect to Odoo. For the latter, check the ``tests_with_odoo`` top directory of this repository. """ diff --git a/anybox/recipe/odoo/tests/test_server.py b/anybox/recipe/odoo/tests/test_server.py index 83fd8012..255727ba 100644 --- a/anybox/recipe/odoo/tests/test_server.py +++ b/anybox/recipe/odoo/tests/test_server.py @@ -21,19 +21,19 @@ class TestingRecipe(ServerRecipe): This is merely to avoid rewriting many tests. """ - release_filenames = {'8.0': 'fake-release-%s.tgz'} - release_dl_url = {'8.0': 'http://release.odoo.test/src/'} + release_filenames = {'10.0': 'fake-release-%s.tgz'} + release_dl_url = {'10.0': 'http://release.odoo.test/src/'} class TestServer(RecipeTestCase): - def make_recipe(self, name='openerp', **options): + def make_recipe(self, name='odoo', **options): self.recipe = TestingRecipe(self.buildout, name, options) def test_retrieve_addons_local(self): """Setting up a local addons line.""" addons_dir = os.path.join(self.buildout_dir, 'addons-custom') - self.make_recipe(version='8.0', addons='local addons-custom') + self.make_recipe(version='10.0', addons='local addons-custom') self.recipe.retrieve_addons() paths = self.recipe.addons_paths @@ -41,20 +41,21 @@ def test_retrieve_addons_local(self): self.assertEquals(paths, [addons_dir]) def test_retrieve_addons_local_standalone(self): - """A local standalone addon is not permitted.""" + """A local standalone addon is permitted.""" addons_dir = os.path.join(self.buildout_dir, 'addons-custom') os.mkdir(addons_dir) - with open(os.path.join(addons_dir, '__openerp__.py'), 'w') as f: + with open(os.path.join(addons_dir, '__manifest__.py'), 'w') as f: f.write("#Empty python package") - self.make_recipe(version='8.0', addons='local addons-custom') - self.assertRaises(UserError, self.recipe.retrieve_addons) + self.make_recipe(version='10.0', addons='local addons-custom') + print self.recipe.retrieve_addons + self.assertTrue(self.recipe.retrieve_addons) def test_retrieve_addons_local_options(self): """Addons options work for 'local' by testing (useless) subdir option. """ custom_dir = os.path.join(self.buildout_dir, 'custom') addons_dir = os.path.join(custom_dir, 'addons') - self.make_recipe(version='8.0', addons='local custom subdir=addons') + self.make_recipe(version='10.0', addons='local custom subdir=addons') self.recipe.retrieve_addons() paths = self.recipe.addons_paths @@ -63,7 +64,7 @@ def test_retrieve_addons_local_options(self): def test_retrieve_addons_vcs(self): """A VCS line in addons.""" - self.make_recipe(version='8.0', addons='fakevcs http://trunk.example ' + self.make_recipe(version='10.0', addons='fakevcs http://trunk.example ' 'addons-trunk rev') # manual creation because fakevcs does nothing but retrieve_addons # has assertions on existence of target directories @@ -80,7 +81,7 @@ def test_retrieve_addons_vcs(self): def test_retrieve_addons_vcs_2(self): """Two VCS lines in addons.""" - self.make_recipe(version='8.0', addons=os.linesep.join(( + self.make_recipe(version='10.0', addons=os.linesep.join(( 'fakevcs http://trunk.example addons-trunk rev', 'fakevcs http://other.example addons-other 76'))) # manual creation because fakevcs does nothing but retrieve_addons @@ -102,7 +103,7 @@ def test_retrieve_addons_vcs_2(self): def test_retrieve_addons_vcs_order(self): """Ordering of addons paths is respected.""" self.make_recipe( - version='8.0', + version='10.0', addons=os.linesep.join( ['fakevcs http://trunk.example addons-%d rev' % d for d in range(10)])) @@ -117,7 +118,7 @@ def test_retrieve_addons_vcs_order(self): self.assertEqual(paths, expected) def test_retrieve_addons_subdir(self): - self.make_recipe(version='8.0', addons='fakevcs lp:openerp-web web ' + self.make_recipe(version='10.0', addons='fakevcs lp:odoo-web web ' 'last:1 subdir=addons bzrinit=branch') # manual creation because fakevcs does nothing but retrieve_addons # has assertions on existence of target directories @@ -127,14 +128,15 @@ def test_retrieve_addons_subdir(self): self.recipe.retrieve_addons() paths = self.recipe.addons_paths self.assertEquals(get_vcs_log(), [ - (web_dir, 'lp:openerp-web', 'last:1', + (web_dir, 'lp:odoo-web', 'last:1', dict(offline=False, clear_locks=False, clean=False, subdir="addons", bzrinit="branch")) ]) self.assertEquals(paths, [web_addons_dir]) def test_retrieve_addons_standalone_grouped(self): - self.make_recipe(version='8.0', addons='fakevcs lp:my-addons1 addons1 ' + self.make_recipe(version='10.0', + addons='fakevcs lp:my-addons1 addons1 ' 'last:1 group=grouped\nfakevcs lp:my-addons2 addons2 ' 'last:1 group=grouped') # manual creation because fakevcs does nothing but retrieve_addons @@ -156,23 +158,23 @@ def test_retrieve_addons_standalone_grouped(self): self.assertEquals(paths, [group_dir]) def test_addons_standalone_oldstyle_prohibited(self): - """Standalone addons must now be declared by the 'group' option.""" + """Standalone addons could be declared by the 'group' option.""" dirname = 'standalone' - self.make_recipe(version='8.0', - addons='fakevcs custom %s last:1' % dirname) + self.make_recipe(version='10.0', + addons='group custom %s last:1' % dirname) dirname = dirname.rstrip('/') # manual creation of our single addon addon_dir = os.path.join(self.buildout_dir, dirname) os.mkdir(addon_dir) - open(os.path.join(addon_dir, '__openerp__.py'), 'w').close() - - self.assertRaises(UserError, self.recipe.retrieve_addons) + open(os.path.join(addon_dir, '__manifest__.py'), 'w').close() + print self.recipe.retrieve_addons + self.assertTrue(self.recipe.retrieve_addons) def test_retrieve_addons_clear_locks(self): """Retrieving addons with vcs-clear-locks option.""" addons_dir = os.path.join(self.buildout_dir, 'addons') - options = dict(version='8.0', addons='fakevcs lp:my-addons addons -1') + options = dict(version='10.0', addons='fakevcs lp:my-addons addons -1') options['vcs-clear-locks'] = 'True' self.make_recipe(**options) self.recipe.retrieve_addons() @@ -182,26 +184,26 @@ def test_retrieve_addons_clear_locks(self): ]) def test_merge_requirements(self): - self.make_recipe(version='8.0') - self.recipe.version_detected = '8.0-1' + self.make_recipe(version='10.0') + self.recipe.version_detected = '10.0-1' self.recipe.merge_requirements() self.assertEquals(set(self.recipe.requirements), set(['anybox.recipe.odoo', - 'openerp'])) + 'odoo'])) def test_merge_requirements_new_project_name(self): """At any point in time, Odoo is prone to change package name.""" self.make_recipe(version='local %s' % os.path.join( TEST_DIR, 'odoo-project-renaming')) - self.recipe.version_detected = '8.0' + self.recipe.version_detected = '10.0' self.recipe.merge_requirements() self.assertEquals(set(self.recipe.requirements), set(['anybox.recipe.odoo', - 'oodooo'])) + 'odoo'])) def test_merge_requirements_gunicorn(self): - self.make_recipe(version='8.0', gunicorn='direct') - self.recipe.version_detected = '8.0-1' + self.make_recipe(version='10.0', gunicorn='direct') + self.recipe.version_detected = '10.0-1' self.recipe.apply_version_dependent_decisions() # TODO make a helper self.recipe.merge_requirements() req = self.recipe.requirements @@ -209,8 +211,8 @@ def test_merge_requirements_gunicorn(self): self.assertTrue('psutil' in req) def test_merge_requirements_devtools(self): - self.make_recipe(version='8.0', with_devtools='true') - self.recipe.version_detected = '8.0-1' + self.make_recipe(version='10.0', with_devtools='true') + self.recipe.version_detected = '10.0-1' self.recipe.merge_requirements() from .. import devtools self.assertTrue(set(devtools.requirements).issubset( @@ -231,17 +233,17 @@ def read_script(self, script_name): def test_retrieve_fixup_addons_check(self): """Test that existence check of addons paths is done.""" - oerp_dir = os.path.join(TEST_DIR, 'odoo80') + oerp_dir = os.path.join(TEST_DIR, 'odoo10') self.make_recipe(version='local %s' % oerp_dir, addons='local addons-custom', ) - self.recipe.version_detected = "8.0.0" + self.recipe.version_detected = "10.0.0" self.recipe.retrieve_addons() self.assertRaises(AssertionError, self.recipe.finalize_addons_paths) def test_forbid_addons_paths_option(self): - oerp_dir = os.path.join(TEST_DIR, 'odoo80') + oerp_dir = os.path.join(TEST_DIR, 'odoo10') self.make_recipe(version='local %s' % oerp_dir, addons='local addons-custom', ) @@ -276,7 +278,7 @@ def install_scripts(self, extra_develop=None, self.recipe.options['eggs'] = os.linesep.join(eggs) self.recipe.install_requirements() - self.recipe.develop(self.recipe.openerp_dir) + self.recipe.develop(self.recipe.odoo_dir) bindir = os.path.join(self.buildout_dir, 'bin') os.mkdir(bindir) @@ -287,10 +289,10 @@ def install_scripts(self, extra_develop=None, def do_test_install_scripts_soft_deps(self, exc=None): """If a soft requirement is missing, the scripts are still generated. """ - self.make_recipe(version='local %s' % os.path.join(TEST_DIR, 'odoo80'), + self.make_recipe(version='local %s' % os.path.join(TEST_DIR, 'odoo10'), gunicorn='direct', with_devtools='true') - self.recipe.version_detected = "8.0-20121003-233130" + self.recipe.version_detected = "10.0-20121003-233130" softreq = 'zztest-softreq' self.recipe.missing_deps_instructions[softreq] = ( @@ -306,19 +308,19 @@ def do_test_install_scripts_soft_deps(self, exc=None): self.exc_distributions[softreq] = exc self.install_scripts(extra_requirements=(softreq,)) - self.assertScripts(('start_openerp', - 'test_openerp', - 'gunicorn_openerp', - 'cron_worker_openerp', + self.assertScripts(('start_odoo', + 'test_odoo', + 'gunicorn_odoo', + 'cron_worker_odoo', )) def test_install_scripts_indirect_soft_deps(self, exc=None): """If a requirement is soft and indirect, UserError is properly raised. """ - self.make_recipe(version='local %s' % os.path.join(TEST_DIR, 'odoo80'), + self.make_recipe(version='local %s' % os.path.join(TEST_DIR, 'odoo10'), gunicorn='direct', with_devtools='true') - self.recipe.version_detected = "8.0" + self.recipe.version_detected = "10.0" somereq = 'zztest-req' softreq = 'zztest-softreq' @@ -379,28 +381,28 @@ def test_install_scripts_soft_deps_user_error_reraise(self): else: self.fail("Expected the same UserError to be reraised") - def test_install_scripts_80(self, with_devtools=True, **kw): + def test_install_scripts_10(self, with_devtools=True, **kw): kw['with_devtools'] = 'true' if with_devtools else 'false' - self.make_recipe(version='local %s' % os.path.join(TEST_DIR, 'odoo80'), + self.make_recipe(version='local %s' % os.path.join(TEST_DIR, 'odoo10'), gunicorn='direct', **kw) - self.recipe.version_detected = "8.0alpha" + self.recipe.version_detected = "10.0alpha" self.recipe.options['options.log_handler'] = ":INFO,werkzeug:WARNING" self.install_scripts() - expected = ['start_openerp', - 'gunicorn_openerp', - 'cron_worker_openerp'] + expected = ['start_odoo', + 'gunicorn_odoo', + 'cron_worker_odoo'] if with_devtools: - expected.append('test_openerp') + expected.append('test_odoo') self.assertScripts(expected) - def test_install_scripts_80_no_devtools(self): - self.test_install_scripts_80(with_devtools=False) + def test_install_scripts_10_no_devtools(self): + self.test_install_scripts_10(with_devtools=False) def test_gunicorn_preload_databases(self, databases='onedb', expected="('onedb',)"): - self.make_recipe(version='local %s' % os.path.join(TEST_DIR, 'odoo80'), + self.make_recipe(version='local %s' % os.path.join(TEST_DIR, 'odoo10'), gunicorn='direct') self.recipe.version_detected = "7.0" self.recipe.options['gunicorn.preload_databases'] = databases @@ -408,9 +410,9 @@ def test_gunicorn_preload_databases(self, databases='onedb', self.install_scripts() - self.assertScripts(['gunicorn_openerp']) + self.assertScripts(['gunicorn_odoo']) gunicorn_conf = os.path.join(self.recipe.etc, - 'gunicorn_openerp.conf.py') + 'gunicorn_odoo.conf.py') self.assertTrue(os.path.exists(gunicorn_conf)) with open(gunicorn_conf) as conf: for line in conf: @@ -421,62 +423,62 @@ def test_gunicorn_preload_databases_multiple(self): self.test_gunicorn_preload_databases(databases='db1\ndb2', expected="('db1', 'db2')") - def test_install_scripts_80_server_wide_modules(self): - self.make_recipe(version='local %s' % os.path.join(TEST_DIR, 'odoo80'), + def test_install_scripts_10_server_wide_modules(self): + self.make_recipe(version='local %s' % os.path.join(TEST_DIR, 'odoo10'), gunicorn='direct', server_wide_modules='anybox_homepage') - self.recipe.version_detected = "7.0alpha" + self.recipe.version_detected = "10.0alpha" self.recipe.options['options.log_handler'] = ":INFO,werkzeug:WARNING" self.install_scripts() self.assertTrue("server_wide_modules=('web', 'anybox_homepage')" - in self.read_script('start_openerp')) + in self.read_script('start_odoo')) with open(os.path.join( - self.buildout_dir, 'etc', 'gunicorn_openerp.conf.py')) as gu: + self.buildout_dir, 'etc', 'gunicorn_odoo.conf.py')) as gu: self.assertTrue( - "openerp.conf.server_wide_modules = " + "odoo.conf.server_wide_modules = " "['web', 'anybox_homepage']\n" in gu) - def test_install_scripts_70_gunicorn_proxied(self): - self.make_recipe(version='local %s' % os.path.join(TEST_DIR, 'odoo80'), + def test_install_scripts_10_gunicorn_proxied(self): + self.make_recipe(version='local %s' % os.path.join(TEST_DIR, 'odoo10'), gunicorn='proxied') - self.recipe.version_detected = "8.0alpha" + self.recipe.version_detected = "10.0alpha" self.install_scripts() - self.assertScripts(('start_openerp', - 'gunicorn_openerp', - 'cron_worker_openerp', + self.assertScripts(('start_odoo', + 'gunicorn_odoo', + 'cron_worker_odoo', )) - def test_parse_openerp_scripts(self): + def test_parse_odoo_scripts(self): self.make_recipe( - version='local %s' % os.path.join(TEST_DIR, 'odoo80'), - openerp_scripts=os.linesep.join(( + version='local %s' % os.path.join(TEST_DIR, 'odoo10'), + odoo_scripts=os.linesep.join(( 'myentry=script_name', 'nosetests command-line-options=-d', 'withargs=withargs arguments=session', - 'myentry=script_name_opt openerp-log-level=error ' + 'myentry=script_name_opt odoo-log-level=error ' 'command-line-options=-d,-f')), ) - self.recipe._parse_openerp_scripts() + self.recipe._parse_odoo_scripts() self.assertEqual( - self.recipe.openerp_scripts, + self.recipe.odoo_scripts, dict(script_name=dict(entry='myentry', command_line_options=[]), withargs=dict(entry="withargs", arguments="session", command_line_options=[]), script_name_opt=dict(entry='myentry', - openerp_log_level='ERROR', + odoo_log_level='ERROR', command_line_options=['-d', '-f']), - nosetests_openerp=dict(entry='nosetests', - command_line_options=['-d']))) + nosetests_odoo=dict(entry='nosetests', + command_line_options=['-d']))) - def test_parse_openerp_scripts_improper_log_level(self): + def test_parse_odoo_scripts_improper_log_level(self): self.make_recipe( - version='local %s' % os.path.join(TEST_DIR, 'odoo80'), - openerp_scripts=('myentry=script_name_opt openerp-log-level=cool ' - 'command-line-options=-d,-f')) - self.assertRaises(UserError, self.recipe._parse_openerp_scripts) + version='local %s' % os.path.join(TEST_DIR, 'odoo10'), + odoo_scripts=('myentry=script_name_opt odoo-log-level=cool ' + 'command-line-options=-d,-f')) + self.assertRaises(UserError, self.recipe._parse_odoo_scripts) diff --git a/buildbot/MANIFEST.cfg b/buildbot/MANIFEST.cfg index 76c22439..d0b5cb08 100644 --- a/buildbot/MANIFEST.cfg +++ b/buildbot/MANIFEST.cfg @@ -6,14 +6,14 @@ bootstrap-virtualenv = True watch = git https://github.com/anybox/anybox.recipe.odoo master build-for = python >= 2.6 < 3.0 -[odoo-recipe-80] +[odoo-recipe-10] # A buildout to test latest version of the Odoo recipe on Odoo 8.0 branch -buildout = git https://github.com/anybox/anybox.recipe.odoo master recipe-80.cfg subdir=buildbot +buildout = git https://github.com/anybox/anybox.recipe.odoo master recipe-10.cfg subdir=buildbot build-for = postgresql == 9.4 post-buildout-steps = install-modules-test nose -nose.tests = anybox.recipe.odoo/tests_with_openerp +nose.tests = anybox.recipe.odoo/tests_with_odoo buildout-part = odoo odoo.use-port = true -watch = git https://github.com/anybox/anybox.recipe.odoo master +watch = git https://github.com/anybox/anybox.recipe.odoo 513b4d91a0af6afce457666cdeff9abcbb425f7e diff --git a/buildbot/recipe-10.cfg b/buildbot/recipe-10.cfg new file mode 100644 index 00000000..3793a8e2 --- /dev/null +++ b/buildbot/recipe-10.cfg @@ -0,0 +1,9 @@ +[buildout] +extends = base_recipe.cfg + +[odoo] +version = git http://github.com/odoo/odoo.git odoo 10.0 +eggs += pyPdf + +[versions] +reportlab = 2.7 diff --git a/tests_with_openerp/README.txt b/tests_with_odoo/README.txt similarity index 100% rename from tests_with_openerp/README.txt rename to tests_with_odoo/README.txt diff --git a/tests_with_openerp/data/VERSION.txt b/tests_with_odoo/data/VERSION.txt similarity index 100% rename from tests_with_openerp/data/VERSION.txt rename to tests_with_odoo/data/VERSION.txt diff --git a/tests_with_openerp/test_session.py b/tests_with_odoo/test_session.py similarity index 95% rename from tests_with_openerp/test_session.py rename to tests_with_odoo/test_session.py index 39fa39b6..10c604f3 100644 --- a/tests_with_openerp/test_session.py +++ b/tests_with_odoo/test_session.py @@ -1,6 +1,6 @@ from unittest import TestCase from anybox.recipe.odoo.runtime.session import Session -from openerp.tests.common import get_db_name +from odoo.tests.common import get_db_name class SessionTestCase(TestCase): diff --git a/tests_with_openerp/test_version.py b/tests_with_odoo/test_version.py similarity index 97% rename from tests_with_openerp/test_version.py rename to tests_with_odoo/test_version.py index 4fa92bb2..499eb5db 100644 --- a/tests_with_openerp/test_version.py +++ b/tests_with_odoo/test_version.py @@ -1,5 +1,5 @@ import os -from openerp.tests.common import TransactionCase +from odoo.tests.common import TransactionCase from anybox.recipe.odoo.runtime.session import Session TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), 'data') From 6b8908069ad62eb958cffa29cbb4b3298defa558 Mon Sep 17 00:00:00 2001 From: archetipo Date: Tue, 4 Oct 2016 14:58:30 +0200 Subject: [PATCH 13/33] Fix Flake8 --- anybox/recipe/odoo/tests/test_base.py | 1 - anybox/recipe/odoo/tests/test_server.py | 43 ++++++++++++++++--------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/anybox/recipe/odoo/tests/test_base.py b/anybox/recipe/odoo/tests/test_base.py index 65304f62..9c8c327b 100644 --- a/anybox/recipe/odoo/tests/test_base.py +++ b/anybox/recipe/odoo/tests/test_base.py @@ -51,7 +51,6 @@ def test_version_nightly_10_0(self): self.assertDownloadUrl( 'http://nightly.odoo.com/10.0/nightly/src/10-0-nightly-latest.tbz') - def test_version_local(self): local_path = 'path/to/local/version' self.make_recipe(version='local ' + local_path) diff --git a/anybox/recipe/odoo/tests/test_server.py b/anybox/recipe/odoo/tests/test_server.py index 255727ba..a1af6678 100644 --- a/anybox/recipe/odoo/tests/test_server.py +++ b/anybox/recipe/odoo/tests/test_server.py @@ -135,10 +135,12 @@ def test_retrieve_addons_subdir(self): self.assertEquals(paths, [web_addons_dir]) def test_retrieve_addons_standalone_grouped(self): - self.make_recipe(version='10.0', - addons='fakevcs lp:my-addons1 addons1 ' - 'last:1 group=grouped\nfakevcs lp:my-addons2 addons2 ' - 'last:1 group=grouped') + self.make_recipe( + version='10.0', + addons='fakevcs lp:my-addons1 addons1 ' + 'last:1 group=grouped\nfakevcs lp:my-addons2 addons2 ' + 'last:1 group=grouped' + ) # manual creation because fakevcs does nothing but retrieve_addons # has assertions on existence of target directories group_dir = os.path.join(self.buildout_dir, 'grouped') @@ -466,19 +468,30 @@ def test_parse_odoo_scripts(self): self.recipe._parse_odoo_scripts() self.assertEqual( self.recipe.odoo_scripts, - dict(script_name=dict(entry='myentry', - command_line_options=[]), - withargs=dict(entry="withargs", arguments="session", - command_line_options=[]), - script_name_opt=dict(entry='myentry', - odoo_log_level='ERROR', - command_line_options=['-d', '-f']), - nosetests_odoo=dict(entry='nosetests', - command_line_options=['-d']))) + dict( + script_name=dict( + entry='myentry', command_line_options=[] + ), + withargs=dict( + entry="withargs", + rguments="session", + command_line_options=[] + ), + script_name_opt=dict( + entry='myentry', odoo_log_level='ERROR', + command_line_options=['-d', '-f'] + ), + nosetests_odoo=dict( + entry='nosetests', command_line_options=['-d']) + ) + ) def test_parse_odoo_scripts_improper_log_level(self): self.make_recipe( version='local %s' % os.path.join(TEST_DIR, 'odoo10'), - odoo_scripts=('myentry=script_name_opt odoo-log-level=cool ' - 'command-line-options=-d,-f')) + odoo_scripts=( + 'myentry=script_name_opt odoo-log-level=cool ' + 'command-line-options=-d,-f' + ) + ) self.assertRaises(UserError, self.recipe._parse_odoo_scripts) From f184add8e66ae2b0b51d071cd9eb87ec13c5ea6d Mon Sep 17 00:00:00 2001 From: archetipo Date: Tue, 4 Oct 2016 15:29:20 +0200 Subject: [PATCH 14/33] FIX test_parse_odoo_scripts --- anybox/recipe/odoo/tests/test_server.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/anybox/recipe/odoo/tests/test_server.py b/anybox/recipe/odoo/tests/test_server.py index a1af6678..3941589d 100644 --- a/anybox/recipe/odoo/tests/test_server.py +++ b/anybox/recipe/odoo/tests/test_server.py @@ -461,10 +461,9 @@ def test_parse_odoo_scripts(self): 'myentry=script_name', 'nosetests command-line-options=-d', 'withargs=withargs arguments=session', - 'myentry=script_name_opt odoo-log-level=error ' + 'myentry=script_name_opt odoo-log-level=ERROR ' 'command-line-options=-d,-f')), ) - self.recipe._parse_odoo_scripts() self.assertEqual( self.recipe.odoo_scripts, @@ -473,8 +472,7 @@ def test_parse_odoo_scripts(self): entry='myentry', command_line_options=[] ), withargs=dict( - entry="withargs", - rguments="session", + entry="withargs", arguments="session", command_line_options=[] ), script_name_opt=dict( From e5b0a9f8d8e32e0a2d51666fe528ec3368af87fc Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Tue, 11 Oct 2016 19:36:36 +0200 Subject: [PATCH 15/33] [IMP] Support server command of older versions --- anybox/recipe/odoo/server.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/anybox/recipe/odoo/server.py b/anybox/recipe/odoo/server.py index 9052c06c..ab10dec0 100644 --- a/anybox/recipe/odoo/server.py +++ b/anybox/recipe/odoo/server.py @@ -8,7 +8,7 @@ from zc.buildout import UserError from base import BaseRecipe from . import devtools -from .utils import option_splitlines, option_strip +from .utils import option_splitlines, option_strip,major_version logger = logging.getLogger(__name__) @@ -183,7 +183,11 @@ def _create_gunicorn_conf(self, qualified_name): def _get_server_command(self): """Return a full path to the main Odoo server command.""" - return join(self.odoo_dir, 'odoo-bin') + if major_version(self.version_detected)[0] >= 10: + base_name = 'odoo-bin' + else: + base_name = 'openerp-server' + return join(self.odoo_dir, base_name) def _parse_odoo_scripts(self): """Parse required scripts from conf.""" From 3ae3701297718663ba39300bb85b15d1f20ba1d2 Mon Sep 17 00:00:00 2001 From: archetipo Date: Wed, 12 Oct 2016 09:40:51 +0200 Subject: [PATCH 16/33] FIX flake 8 --- anybox/recipe/odoo/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anybox/recipe/odoo/server.py b/anybox/recipe/odoo/server.py index ab10dec0..a633f0a6 100644 --- a/anybox/recipe/odoo/server.py +++ b/anybox/recipe/odoo/server.py @@ -8,7 +8,7 @@ from zc.buildout import UserError from base import BaseRecipe from . import devtools -from .utils import option_splitlines, option_strip,major_version +from .utils import option_splitlines, option_strip, major_version logger = logging.getLogger(__name__) From 96076567bac3329cba55b61c59781c7670c7a02b Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sun, 16 Oct 2016 12:49:15 +0200 Subject: [PATCH 17/33] Maintain compatilbility with <10 version --- anybox/recipe/odoo/runtime/patch_odoo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/anybox/recipe/odoo/runtime/patch_odoo.py b/anybox/recipe/odoo/runtime/patch_odoo.py index 02dd669f..589ed672 100644 --- a/anybox/recipe/odoo/runtime/patch_odoo.py +++ b/anybox/recipe/odoo/runtime/patch_odoo.py @@ -12,7 +12,10 @@ def do_patch(gevent_script_path): isolated from the actual process management logic in the original. """ - from odoo.service.server import PreforkServer, stripped_sys_argv + try: + from odoo.service.server import PreforkServer, stripped_sys_argv + except ImportError: + from openerp.service.server import PreforkServer, stripped_sys_argv def long_polling_spawn(server): nargs = stripped_sys_argv() From 47fcb6561d04727667778d9aad30d76afd9630cb Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Sat, 15 Oct 2016 17:16:58 +0200 Subject: [PATCH 18/33] [FIX] Add required gevent argument for Odoo 10.0 --- anybox/recipe/odoo/runtime/patch_odoo.py | 6 ++++++ anybox/recipe/odoo/tests/test_base.py | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/anybox/recipe/odoo/runtime/patch_odoo.py b/anybox/recipe/odoo/runtime/patch_odoo.py index 589ed672..fc3fb8e8 100644 --- a/anybox/recipe/odoo/runtime/patch_odoo.py +++ b/anybox/recipe/odoo/runtime/patch_odoo.py @@ -20,6 +20,12 @@ def do_patch(gevent_script_path): def long_polling_spawn(server): nargs = stripped_sys_argv() nargs[0] = gevent_script_path + try: # Add required gevent argument for Odoo 10.0 + from odoo.release import version_info + if version_info[0] >= 10: + nargs.insert(1, 'gevent') + except ImportError: + pass popen = subprocess.Popen(nargs) server.long_polling_pid = popen.pid diff --git a/anybox/recipe/odoo/tests/test_base.py b/anybox/recipe/odoo/tests/test_base.py index 9c8c327b..f325509f 100644 --- a/anybox/recipe/odoo/tests/test_base.py +++ b/anybox/recipe/odoo/tests/test_base.py @@ -34,9 +34,8 @@ def get_source_url(self): def assertDownloadUrl(self, url): """Assert that main software is 'downloadable' with given url.""" - source = self.recipe.sources[main_software] - self.assertEquals(source[0], 'downloadable') - self.assertEquals(source[1], url) + self.assertEquals(self.get_source_type(), 'downloadable') + self.assertEquals(self.get_source_url(), url) def test_version_release_10_0(self): self.make_recipe(version='10.0') From 7a4fbcee5b02de70cbe2a5b16643d3bcf3c0d566 Mon Sep 17 00:00:00 2001 From: archetipo Date: Fri, 18 Nov 2016 18:03:00 +0100 Subject: [PATCH 19/33] [FIX] some remarks --- anybox/recipe/odoo/base.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/anybox/recipe/odoo/base.py b/anybox/recipe/odoo/base.py index 8d4f8a6d..9e31a202 100644 --- a/anybox/recipe/odoo/base.py +++ b/anybox/recipe/odoo/base.py @@ -257,7 +257,10 @@ def parse_version(self): if len(version_split) == 1: # version can be a simple version name, such as 6.1-1 - major_wanted = self.version_wanted[:4] + if len(self.version_wanted.split('.')[0]) == 2: + major_wanted = self.version_wanted[:4] + elif len(self.version_wanted.split('.')[0]) == 1: + major_wanted = self.version_wanted[:3] pattern = self.release_filenames[major_wanted] if pattern is None: raise UserError('Odoo version %r' @@ -891,7 +894,7 @@ def retrieve_addons(self): if subdir: addons_dir = join(addons_dir, subdir) - manifest = os.path.join(addons_dir, '__odoo__.py') + manifest = os.path.join(addons_dir, '__manifest__.py') manifest_pre_v6 = os.path.join(addons_dir, '__terp__.py') if os.path.isfile(manifest) or os.path.isfile(manifest_pre_v6): raise UserError("Standalone addons such as %r " @@ -1621,7 +1624,7 @@ def insert_odoo_git_addons(self, base_addons): """Insert the standard, non-base addons bundled within Odoo git repo. See `lp:1327756 - `_ + `_ These addons are also part of the Github branch for prior versions, therefore we cannot rely on version knowledge; we check for existence @@ -1693,7 +1696,7 @@ def buildout_cfg_name(self, argv=None): except ValueError: continue else: - return argv[i+1] + return argv[i + 1] # --config=FILE syntax prefix = "--config=" From 44a2d001ef7c8bd105bf0666c2bdff2884e86ef4 Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Tue, 29 Nov 2016 22:17:02 +0100 Subject: [PATCH 20/33] manage some import to be compatible over odoo 8 and 10 --- anybox/recipe/odoo/runtime/session.py | 25 ++++++++++++++++++------- anybox/recipe/odoo/server.py | 12 ++++++++++-- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/anybox/recipe/odoo/runtime/session.py b/anybox/recipe/odoo/runtime/session.py index f6b6d6b0..0650acf6 100644 --- a/anybox/recipe/odoo/runtime/session.py +++ b/anybox/recipe/odoo/runtime/session.py @@ -7,18 +7,29 @@ try: - import odoo + import openerp as odoo except ImportError: - warnings.warn("This must be imported with a buildout odoo recipe " - "driven sys.path", RuntimeWarning) + try: + import odoo + except ImportError: + warnings.warn("This must be imported with a buildout odoo recipe " + "driven sys.path", RuntimeWarning) + else: + try: + from odoo.cli import server as startup + except ImportError: + from .backports.cli import server as startup + from odoo.tools import config + from odoo import SUPERUSER_ID + from odoo.tools.parse_version import parse_version else: try: - from odoo.cli import server as startup + from openerp.cli import server as startup except ImportError: from .backports.cli import server as startup - from odoo.tools import config - from odoo import SUPERUSER_ID - from odoo.tools.parse_version import parse_version + from openerp.tools import config + from openerp import SUPERUSER_ID + from openerp.tools.parse_version import parse_version from optparse import OptionParser # we support python >= 2.6 diff --git a/anybox/recipe/odoo/server.py b/anybox/recipe/odoo/server.py index a633f0a6..bafb4160 100644 --- a/anybox/recipe/odoo/server.py +++ b/anybox/recipe/odoo/server.py @@ -102,7 +102,12 @@ def _create_default_config(self): self.options.setdefault('options.admin_passwd', '') sys.path.append(self.odoo_dir) sys.path.extend([egg.location for egg in self.ws]) - from odoo.tools.config import configmanager + + try: + from odoo.tools.config import configmanager + except ImportError: + from openerp.tools.config import configmanager + configmanager(self.config_path).save() def _create_gunicorn_conf(self, qualified_name): @@ -428,7 +433,10 @@ def _install_interpreter(self): " print('Then you can issue commands such as:')", " print(\"" " session.registry('res.users').browse(session.cr, 1, 1)\")", - " from odoo import release", + " try:", + " from openerp import release", + " except ImportError:" + " from odoo import release", " from anybox.recipe.odoo.utils import major_version", " if major_version(release.version)[0] >= 8:", " print('Or using new api:')", From 21e13654c3319e53261551067c53ecae6c52e4e7 Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Tue, 29 Nov 2016 22:48:32 +0100 Subject: [PATCH 21/33] take care some of my reviews regarding odoo8 to 10 compatiblity --- anybox/recipe/odoo/base.py | 4 ++-- anybox/recipe/odoo/runtime/session.py | 4 ++-- anybox/recipe/odoo/server.py | 9 ++++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/anybox/recipe/odoo/base.py b/anybox/recipe/odoo/base.py index 9e31a202..7ebf965a 100644 --- a/anybox/recipe/odoo/base.py +++ b/anybox/recipe/odoo/base.py @@ -895,8 +895,8 @@ def retrieve_addons(self): addons_dir = join(addons_dir, subdir) manifest = os.path.join(addons_dir, '__manifest__.py') - manifest_pre_v6 = os.path.join(addons_dir, '__terp__.py') - if os.path.isfile(manifest) or os.path.isfile(manifest_pre_v6): + manifest_pre_v10 = os.path.join(addons_dir, '__openerp__.py') + if os.path.isfile(manifest) or os.path.isfile(manifest_pre_v10): raise UserError("Standalone addons such as %r " "are now supported by means " "of the explicit 'group' option. Please " diff --git a/anybox/recipe/odoo/runtime/session.py b/anybox/recipe/odoo/runtime/session.py index 0650acf6..22b08f75 100644 --- a/anybox/recipe/odoo/runtime/session.py +++ b/anybox/recipe/odoo/runtime/session.py @@ -201,7 +201,7 @@ def init_environments(self): See :class:``openerp.api.Environment`` for explanations about environments. - For Odoo/Odoo versions prior to the new style API merge, this + For OpenERP/Odoo versions prior to the new style API merge, this is a no-op. This thread-local ``environments`` is initialized and cleaned with @@ -499,7 +499,7 @@ def browse_ref(self, external_id): "browse_ref requires a fully qualified parameter: " "'module.identifier'" ) - return self.env.ref(external_id).browse() + return self.env.ref(external_id) def handle_command_line_options(self, to_handle): """Handle prescribed command line options and eat them. diff --git a/anybox/recipe/odoo/server.py b/anybox/recipe/odoo/server.py index bafb4160..e0f2529a 100644 --- a/anybox/recipe/odoo/server.py +++ b/anybox/recipe/odoo/server.py @@ -78,7 +78,7 @@ def merge_requirements(self, reqs=None): Once 'odoo' is required, zc.recipe.egg will take it into account and put it in needed scripts, interpreters etc. - Historically, in ``anybox.recipe.odoo`` this used to take care + Historically, in ``anybox.recipe.openerp`` this used to take care of adding Pillow, which is now in Odoo's ``setup.py``. """ odoo_dir = getattr(self, 'odoo_dir', None) @@ -136,7 +136,10 @@ def _create_gunicorn_conf(self, qualified_name): f = open(join(self.etc, qualified_name + '.conf.py'), 'w') conf = """'''Gunicorn configuration script. Generated by buildout. Do NOT edit.''' -import odoo +try: + import openerp as odoo +except ImportError: + import odoo bind = %(bind)r pidfile = %(qualified_name)r + '.pid' workers = %(workers)s @@ -435,7 +438,7 @@ def _install_interpreter(self): " session.registry('res.users').browse(session.cr, 1, 1)\")", " try:", " from openerp import release", - " except ImportError:" + " except ImportError:", " from odoo import release", " from anybox.recipe.odoo.utils import major_version", " if major_version(release.version)[0] >= 8:", From c0b860dab28d6b46a048259fd0ef2e8d0a1b59bf Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Fri, 9 Dec 2016 15:11:50 +0100 Subject: [PATCH 22/33] [FIX] Restore use of old registry in older releases --- anybox/recipe/odoo/base.py | 2 +- anybox/recipe/odoo/runtime/session.py | 46 ++++++++++++++++++++------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/anybox/recipe/odoo/base.py b/anybox/recipe/odoo/base.py index 7ebf965a..ef1246d0 100644 --- a/anybox/recipe/odoo/base.py +++ b/anybox/recipe/odoo/base.py @@ -1674,7 +1674,7 @@ def cleanup_odoo_dir(self): # Nothing guarantees that this method is called after develop(). # It is in practice now, but one day, the extraction as a separate # script of freeze/extract will become a reality. - for proj_name in ('odoo', 'odoo'): + for proj_name in ('openerp', 'odoo'): egg_info_dir = join(self.odoo_dir, proj_name + '.egg-info') if os.path.exists(egg_info_dir): shutil.rmtree(egg_info_dir) diff --git a/anybox/recipe/odoo/runtime/session.py b/anybox/recipe/odoo/runtime/session.py index 22b08f75..4e3a61e5 100644 --- a/anybox/recipe/odoo/runtime/session.py +++ b/anybox/recipe/odoo/runtime/session.py @@ -190,9 +190,12 @@ def open(self, db=None, with_demo=False): self.init_cursor() self.uid = SUPERUSER_ID self.init_environments() - self.context = self.env['res.users'].context_get() if hasattr(odoo, 'api'): - self.env.context = self.context + self.context = self.env['res.users'].context_get() + self.env = self.env.with_context(self.context) + else: + self.context = self.registry('res.users').context_get( + self.cr, self.uid) def init_environments(self): """Enter the environments context manager, but don't leave it @@ -294,9 +297,12 @@ def db_version(self): db_version = getattr(self, '_db_version', None) if db_version is not None: return db_version - - db_version = self.env['ir.config_parameter'].get_param( - self._version_parameter_name) + if hasattr(odoo, 'api'): + db_version = self.env['ir.config_parameter'].get_param( + self._version_parameter_name) + else: + db_version = self.registry('ir.config_parameter').get_param( + self.cr, self.uid, self._version_parameter_name) if not db_version: # as usual Odoo thinks its simpler to use False as None # restoring sanity ASAP @@ -308,8 +314,12 @@ def db_version(self): @db_version.setter def db_version(self, version): - self.env['ir.config_parameter'].set_param( - self._version_parameter_name, str(version)) + if hasattr(odoo, 'api'): + self.env['ir.config_parameter'].set_param( + self._version_parameter_name, str(version)) + else: + self.env['ir.config_parameter'].set_param( + self._version_parameter_name, str(version)) self._db_version = OdooVersion(version) @property @@ -340,7 +350,10 @@ def update_modules_list(self): This is necessary prior to install of any new module. """ - self.env['ir.module.module'].update_list() + if hasattr(odoo, 'api'): + self.env['ir.module.module'].update_list() + else: + self.registry('ir.module.module').update_list(self.cr, self.uid) def init_cursor(self): db = getattr(self._registry, 'db', None) @@ -355,7 +368,7 @@ def init_cursor(self): def registry(self, model): """Lookup model by name and return a ready-to-work instance.""" - if self.env: + if hasattr(odoo, 'api'): return self.env[model] else: return self._registry.get(model) @@ -485,7 +498,14 @@ def ref(self, external_id): raise ValueError( "ref requires a fully qualified parameter: 'module.identifier'" ) - return self.env.ref(external_id).id + + if hasattr(odoo, 'api'): + return self.env.ref(external_id).id + ir_model_data = self.registry('ir.model.data') + module, name = external_id.split('.', 1) + _model, ref_id = ir_model_data.get_object_reference( + self.cr, self.uid, module, name) + return ref_id def browse_ref(self, external_id): """Return ir.model.data browse object from its external identifier. @@ -499,7 +519,11 @@ def browse_ref(self, external_id): "browse_ref requires a fully qualified parameter: " "'module.identifier'" ) - return self.env.ref(external_id) + if hasattr(odoo, 'api'): + return self.env.ref(external_id) + ir_model_data = self.registry('ir.model.data') + module, name = external_id.split('.', 1) + return ir_model_data.get_object(self.cr, self.uid, module, name) def handle_command_line_options(self, to_handle): """Handle prescribed command line options and eat them. From c26750dffff81d79ddc4e0d3201db8f8a5a11d41 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Tue, 13 Dec 2016 20:35:16 +0100 Subject: [PATCH 23/33] [FIX] Get an env with a particular context --- anybox/recipe/odoo/runtime/session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anybox/recipe/odoo/runtime/session.py b/anybox/recipe/odoo/runtime/session.py index 4e3a61e5..3020f142 100644 --- a/anybox/recipe/odoo/runtime/session.py +++ b/anybox/recipe/odoo/runtime/session.py @@ -192,7 +192,7 @@ def open(self, db=None, with_demo=False): self.init_environments() if hasattr(odoo, 'api'): self.context = self.env['res.users'].context_get() - self.env = self.env.with_context(self.context) + self.env = odoo.api.Environment(self.cr, self.uid, self.context) else: self.context = self.registry('res.users').context_get( self.cr, self.uid) From 0170299bd577fafbee92d8422da0e4d2aa27e1ac Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Thu, 15 Dec 2016 16:49:17 +0100 Subject: [PATCH 24/33] keep v8.0 compatibility while initiate db likes: bin/upgrade_odoo -d dbname --init-load-demo-data --- anybox/recipe/odoo/runtime/upgrade.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/anybox/recipe/odoo/runtime/upgrade.py b/anybox/recipe/odoo/runtime/upgrade.py index 0f245e3f..f47fd50d 100644 --- a/anybox/recipe/odoo/runtime/upgrade.py +++ b/anybox/recipe/odoo/runtime/upgrade.py @@ -81,7 +81,11 @@ def upgrade(upgrade_script, upgrade_callable, conf, buildout_dir): session = Session(conf, buildout_dir) - from odoo.tools import config + try: + from odoo.tools import config + except ImportError: + from openerp.tools import config + config['logfile'] = log_path config['log-level'] = log_level From 94e30d9f1cba8f7120e29495b1689627260d7f2b Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Thu, 15 Dec 2016 17:54:20 +0100 Subject: [PATCH 25/33] [FIX] registry can't return new style model if there is no env That happen in case user in upgrade script use the old api syntax on odoo 8.0 --- anybox/recipe/odoo/runtime/session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anybox/recipe/odoo/runtime/session.py b/anybox/recipe/odoo/runtime/session.py index 3020f142..e68db7a8 100644 --- a/anybox/recipe/odoo/runtime/session.py +++ b/anybox/recipe/odoo/runtime/session.py @@ -368,7 +368,7 @@ def init_cursor(self): def registry(self, model): """Lookup model by name and return a ready-to-work instance.""" - if hasattr(odoo, 'api'): + if hasattr(odoo, 'env'): return self.env[model] else: return self._registry.get(model) From c502250cc29b68df6aa28cadae58506196faa3bb Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Thu, 15 Dec 2016 18:15:41 +0100 Subject: [PATCH 26/33] [buildbot] add builder for odoo8/odoo9 and fix builder 10 config --- buildbot/MANIFEST.cfg | 17 +++++++++++++---- buildbot/base_recipe.cfg | 2 +- buildbot/{recipe-10.cfg => recipe-100.cfg} | 0 buildbot/recipe-80.cfg | 1 + buildbot/recipe-90.cfg | 10 ++++++++++ 5 files changed, 25 insertions(+), 5 deletions(-) rename buildbot/{recipe-10.cfg => recipe-100.cfg} (100%) create mode 100644 buildbot/recipe-90.cfg diff --git a/buildbot/MANIFEST.cfg b/buildbot/MANIFEST.cfg index d0b5cb08..dd317d8d 100644 --- a/buildbot/MANIFEST.cfg +++ b/buildbot/MANIFEST.cfg @@ -6,9 +6,9 @@ bootstrap-virtualenv = True watch = git https://github.com/anybox/anybox.recipe.odoo master build-for = python >= 2.6 < 3.0 -[odoo-recipe-10] -# A buildout to test latest version of the Odoo recipe on Odoo 8.0 branch -buildout = git https://github.com/anybox/anybox.recipe.odoo master recipe-10.cfg subdir=buildbot +[odoo-recipe-100] +# A buildout to test latest version of the Odoo recipe on Odoo 10.0 branch +buildout = git https://github.com/anybox/anybox.recipe.odoo master recipe-100.cfg subdir=buildbot build-for = postgresql == 9.4 post-buildout-steps = install-modules-test @@ -16,4 +16,13 @@ post-buildout-steps = nose.tests = anybox.recipe.odoo/tests_with_odoo buildout-part = odoo odoo.use-port = true -watch = git https://github.com/anybox/anybox.recipe.odoo 513b4d91a0af6afce457666cdeff9abcbb425f7e +watch = git https://github.com/anybox/anybox.recipe.odoo master + +[odoo-recipe-90] +inherit = odoo-recipe-100 +buildout = git https://github.com/anybox/anybox.recipe.odoo master recipe-90.cfg subdir=buildbot +nose.tests = anybox.recipe.odoo/tests_with_openerp + +[odoo-recipe-80] +inherit = odoo-recipe-90 +buildout = git https://github.com/anybox/anybox.recipe.odoo master recipe-80.cfg subdir=buildbot diff --git a/buildbot/base_recipe.cfg b/buildbot/base_recipe.cfg index 8a4e69e3..73aeb749 100644 --- a/buildbot/base_recipe.cfg +++ b/buildbot/base_recipe.cfg @@ -12,7 +12,7 @@ options.xmlrpc = False options.xmlrpcs = False options.netrpc = False eggs = nose -openerp_scripts = nosetests=nosetests command-line-options=-d +odoo_scripts = nosetests=nosetests command-line-options=-d [versions] reportlab = 2.7 diff --git a/buildbot/recipe-10.cfg b/buildbot/recipe-100.cfg similarity index 100% rename from buildbot/recipe-10.cfg rename to buildbot/recipe-100.cfg diff --git a/buildbot/recipe-80.cfg b/buildbot/recipe-80.cfg index bce27963..524b5933 100644 --- a/buildbot/recipe-80.cfg +++ b/buildbot/recipe-80.cfg @@ -4,6 +4,7 @@ extends = base_recipe.cfg [odoo] version = git http://github.com/odoo/odoo.git odoo 8.0 eggs += pyPdf +openerp_scripts = nosetests=nosetests command-line-options=-d [versions] reportlab = 2.7 diff --git a/buildbot/recipe-90.cfg b/buildbot/recipe-90.cfg new file mode 100644 index 00000000..6fe57d19 --- /dev/null +++ b/buildbot/recipe-90.cfg @@ -0,0 +1,10 @@ +[buildout] +extends = base_recipe.cfg + +[odoo] +version = git http://github.com/odoo/odoo.git odoo 9.0 +eggs += pyPdf +openerp_scripts = nosetests=nosetests command-line-options=-d + +[versions] +reportlab = 2.7 From 44d0bedfaee75b2bbb5ab072c22d84e74bdb88ee Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Fri, 16 Dec 2016 11:19:56 +0100 Subject: [PATCH 27/33] Fix integration test, breaks compatibility with openerp 7.0 --- anybox/recipe/odoo/runtime/session.py | 64 ++++++++------------------- tests_with_odoo/test_session.py | 42 +++++++++++++++--- tests_with_odoo/test_version.py | 15 +++---- 3 files changed, 61 insertions(+), 60 deletions(-) diff --git a/anybox/recipe/odoo/runtime/session.py b/anybox/recipe/odoo/runtime/session.py index e68db7a8..238f3949 100644 --- a/anybox/recipe/odoo/runtime/session.py +++ b/anybox/recipe/odoo/runtime/session.py @@ -190,12 +190,8 @@ def open(self, db=None, with_demo=False): self.init_cursor() self.uid = SUPERUSER_ID self.init_environments() - if hasattr(odoo, 'api'): - self.context = self.env['res.users'].context_get() - self.env = odoo.api.Environment(self.cr, self.uid, self.context) - else: - self.context = self.registry('res.users').context_get( - self.cr, self.uid) + self.context = self.env['res.users'].context_get() + self.env = odoo.api.Environment(self.cr, self.uid, self.context) def init_environments(self): """Enter the environments context manager, but don't leave it @@ -221,12 +217,11 @@ def init_environments(self): self._environments_gen_context = gen_factory().gen self._environments_gen_context.next() - if hasattr(odoo, 'api'): - self.env = odoo.api.Environment( - self.cr, self.uid, getattr( - self, 'context', {} - ) + self.env = odoo.api.Environment( + self.cr, self.uid, getattr( + self, 'context', {} ) + ) def clean_environments(self, reinit=True): """Cleans the thread-local environment. @@ -297,12 +292,8 @@ def db_version(self): db_version = getattr(self, '_db_version', None) if db_version is not None: return db_version - if hasattr(odoo, 'api'): - db_version = self.env['ir.config_parameter'].get_param( - self._version_parameter_name) - else: - db_version = self.registry('ir.config_parameter').get_param( - self.cr, self.uid, self._version_parameter_name) + db_version = self.env['ir.config_parameter'].get_param( + self._version_parameter_name) if not db_version: # as usual Odoo thinks its simpler to use False as None # restoring sanity ASAP @@ -314,12 +305,8 @@ def db_version(self): @db_version.setter def db_version(self, version): - if hasattr(odoo, 'api'): - self.env['ir.config_parameter'].set_param( - self._version_parameter_name, str(version)) - else: - self.env['ir.config_parameter'].set_param( - self._version_parameter_name, str(version)) + self.env['ir.config_parameter'].set_param( + self._version_parameter_name, str(version)) self._db_version = OdooVersion(version) @property @@ -350,10 +337,7 @@ def update_modules_list(self): This is necessary prior to install of any new module. """ - if hasattr(odoo, 'api'): - self.env['ir.module.module'].update_list() - else: - self.registry('ir.module.module').update_list(self.cr, self.uid) + self.env['ir.module.module'].update_list() def init_cursor(self): db = getattr(self._registry, 'db', None) @@ -367,11 +351,12 @@ def init_cursor(self): self.cr = db.cursor() def registry(self, model): - """Lookup model by name and return a ready-to-work instance.""" - if hasattr(odoo, 'env'): - return self.env[model] - else: - return self._registry.get(model) + """Lookup model by name and return a ready-to-work instance to + use the old api. However you must use ``session.env['model']`` to + get the instance in the new api (from version 8), this expect to raise + in version 10 + """ + return self._registry.get(model) def rollback(self): self.cr.rollback() @@ -498,14 +483,7 @@ def ref(self, external_id): raise ValueError( "ref requires a fully qualified parameter: 'module.identifier'" ) - - if hasattr(odoo, 'api'): - return self.env.ref(external_id).id - ir_model_data = self.registry('ir.model.data') - module, name = external_id.split('.', 1) - _model, ref_id = ir_model_data.get_object_reference( - self.cr, self.uid, module, name) - return ref_id + return self.env.ref(external_id).id def browse_ref(self, external_id): """Return ir.model.data browse object from its external identifier. @@ -519,11 +497,7 @@ def browse_ref(self, external_id): "browse_ref requires a fully qualified parameter: " "'module.identifier'" ) - if hasattr(odoo, 'api'): - return self.env.ref(external_id) - ir_model_data = self.registry('ir.model.data') - module, name = external_id.split('.', 1) - return ir_model_data.get_object(self.cr, self.uid, module, name) + return self.env.ref(external_id) def handle_command_line_options(self, to_handle): """Handle prescribed command line options and eat them. diff --git a/tests_with_odoo/test_session.py b/tests_with_odoo/test_session.py index 10c604f3..765d5d1b 100644 --- a/tests_with_odoo/test_session.py +++ b/tests_with_odoo/test_session.py @@ -1,33 +1,61 @@ from unittest import TestCase from anybox.recipe.odoo.runtime.session import Session -from odoo.tests.common import get_db_name +try: + from odoo.tests.common import get_db_name + from odoo.release import version_info +except ImportError: + from openerp.tests.common import get_db_name + from openerp.release import version_info class SessionTestCase(TestCase): def setUp(self): super(SessionTestCase, self).setUp() - self.session = Session(None, None, parse_config=False) + self.open_session() + + def tearDown(self): + self.session.close() def open_session(self): + self.session = Session(None, None, parse_config=False) self.session.open(db=get_db_name()) def test_env_after_install_module(self): - self.open_session() self.assertAdminPresentWithV8API() self.session.install_modules(['report']) self.assertAdminPresentWithV8API() - self.session.close() + + def assertAdminPresentWithV7API(self): + user_mdl = self.session.registry('res.users') + admin_id = user_mdl.search( + self.session.cr, self.session.uid, [('login', '=', 'admin')] + )[0] + + self.assertEqual( + u"Administrator", + user_mdl.read( + self.session.cr, self.session.uid, admin_id, ['name'] + )['name'] + ) def assertAdminPresentWithV8API(self): self.assertEqual( u"Administrator", - self.session.env['res.users'].search([('login', '=', 'admin')]).name + self.session.env['res.users'].search( + [('login', '=', 'admin')] + ).name ) def test_env_context(self): - self.open_session() self.assertTrue(self.session.env.context.get('tz')) self.session.install_modules(['web_tests']) self.assertTrue(self.session.env.context.get('tz')) - self.session.close() + + def test_registry(self): + # If version 8, 9 registry should be working + self.assertAdminPresentWithV8API() + if version_info[0] >= 10: + self.assertAdminPresentWithV7API() + else: + self.assertAdminPresentWithV7API() diff --git a/tests_with_odoo/test_version.py b/tests_with_odoo/test_version.py index 499eb5db..3a513330 100644 --- a/tests_with_odoo/test_version.py +++ b/tests_with_odoo/test_version.py @@ -1,6 +1,9 @@ import os -from odoo.tests.common import TransactionCase from anybox.recipe.odoo.runtime.session import Session +try: + from odoo.tests.common import TransactionCase, get_db_name +except: + from openerp.tests.common import TransactionCase, get_db_name TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), 'data') @@ -9,13 +12,11 @@ class VersionTestCase(TransactionCase): def setUp(self): super(VersionTestCase, self).setUp() - self.initSession() + self.session = self.initSession() def initSession(self): - session = self.session = Session(None, None, parse_config=False) - session.registry = self.registry - session.cr = self.cr - session.uid = self.uid + session = Session(None, None, parse_config=False) + session.open(db=get_db_name()) session.buildout_dir = TEST_DATA_DIR return session @@ -34,8 +35,6 @@ def test_db_version(self): session = self.session session.db_version = '1.2.3a3' self.assertEqual(str(session.db_version), '1.2.3a3') - - session = self.initSession() self.assertEqual(str(session.db_version), '1.2.3a3') self.assertTrue(session.db_version < '1.2.3') self.assertTrue(session.db_version < (1, 2, 3)) From 159b173a5cf89506dc6719ef82d984dfb30263b7 Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Fri, 16 Dec 2016 12:27:19 +0100 Subject: [PATCH 28/33] =?UTF-8?q?[buildbot=20config]=C2=A0add=20tag=20to?= =?UTF-8?q?=20easly=20differenciate=20a.r.odoo=20and=20a.r.openerp=20build?= =?UTF-8?q?ers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildbot/MANIFEST.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildbot/MANIFEST.cfg b/buildbot/MANIFEST.cfg index dd317d8d..2f6815eb 100644 --- a/buildbot/MANIFEST.cfg +++ b/buildbot/MANIFEST.cfg @@ -1,5 +1,5 @@ [DEFAULT] -build-category = recipe +build-category = recipe,a.r.odoo bootstrap-virtualenv = True [a.r.odoo] From 91940c233e11f74f095af481f430ebc47e215f71 Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Fri, 16 Dec 2016 12:47:50 +0100 Subject: [PATCH 29/33] [integration test] as expect fix integration test for odoo 10.0 --- tests_with_odoo/test_session.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests_with_odoo/test_session.py b/tests_with_odoo/test_session.py index 765d5d1b..ae000c5e 100644 --- a/tests_with_odoo/test_session.py +++ b/tests_with_odoo/test_session.py @@ -56,6 +56,14 @@ def test_registry(self): # If version 8, 9 registry should be working self.assertAdminPresentWithV8API() if version_info[0] >= 10: - self.assertAdminPresentWithV7API() + # Type error because we a registry exists and return + # an odoo.api.res.users class which does not know about + # old api signature methods, we are getting an error likes:: + # + # TypeError: unbound method search() must be called with + # res.users instance as first argument (got Cursor instance + # instead) + with self.assertRaises(TypeError): + self.assertAdminPresentWithV7API() else: self.assertAdminPresentWithV7API() From ea8d1640d6412d63b435a4acb45f5b446747b283 Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Wed, 21 Dec 2016 15:57:08 +0100 Subject: [PATCH 30/33] Using odoo 10.0 RegistryManager.get behavior change it do not sent properties likes force_demo/status/update_modules so instanciate a we needs to instaniate new registry while installing module. In any odoo version we were already getting a new registry as install step occured while loading the registry. --- anybox/recipe/odoo/runtime/session.py | 2 +- tests_with_odoo/test_session.py | 28 +++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/anybox/recipe/odoo/runtime/session.py b/anybox/recipe/odoo/runtime/session.py index 238f3949..2b6db4cd 100644 --- a/anybox/recipe/odoo/runtime/session.py +++ b/anybox/recipe/odoo/runtime/session.py @@ -465,7 +465,7 @@ def install_modules(self, modules, db=None, update_modules_list=True, config['without_demo'] = not getattr(self, 'with_demo', open_with_demo) for module in modules: config['init'][module] = 1 - self._registry = odoo.modules.registry.RegistryManager.get( + self._registry = odoo.modules.registry.RegistryManager.new( db, update_module=True, force_demo=self.with_demo) config['init'].clear() config['without_demo'] = saved_without_demo diff --git a/tests_with_odoo/test_session.py b/tests_with_odoo/test_session.py index ae000c5e..3fafd447 100644 --- a/tests_with_odoo/test_session.py +++ b/tests_with_odoo/test_session.py @@ -7,15 +7,26 @@ from openerp.tests.common import get_db_name from openerp.release import version_info +TEST_MODULE = 'report' + class SessionTestCase(TestCase): def setUp(self): super(SessionTestCase, self).setUp() self.open_session() + # This could be cleaner as uninstall module is not only a state but + # removing db structure and data, but at that time the state of the + # module is the only thing we care in this state so we don't needs to + # reload the session twice + report_module = self.session.env['ir.module.module'].search( + [('name', '=', TEST_MODULE)] + ) + report_module.state = 'uninstalled' def tearDown(self): self.session.close() + super(SessionTestCase, self).tearDown() def open_session(self): self.session = Session(None, None, parse_config=False) @@ -23,7 +34,7 @@ def open_session(self): def test_env_after_install_module(self): self.assertAdminPresentWithV8API() - self.session.install_modules(['report']) + self.session.install_modules([TEST_MODULE]) self.assertAdminPresentWithV8API() def assertAdminPresentWithV7API(self): @@ -49,7 +60,7 @@ def assertAdminPresentWithV8API(self): def test_env_context(self): self.assertTrue(self.session.env.context.get('tz')) - self.session.install_modules(['web_tests']) + self.session.install_modules([TEST_MODULE]) self.assertTrue(self.session.env.context.get('tz')) def test_registry(self): @@ -67,3 +78,16 @@ def test_registry(self): self.assertAdminPresentWithV7API() else: self.assertAdminPresentWithV7API() + + def assertModuleState(self, module_name, expected_state): + self.assertEqual( + expected_state, + self.session.env['ir.module.module'].search( + [('name', '=', module_name)] + ).state + ) + + def test_insall_module(self): + self.assertModuleState('report', 'uninstalled') + self.session.install_modules([TEST_MODULE]) + self.assertModuleState('report', 'installed') From 1d6f676566bee5bd7ccf67d7ea4cfc76ddd77708 Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Fri, 23 Dec 2016 18:25:13 +0100 Subject: [PATCH 31/33] fix longpolling for odoo8 --- anybox/recipe/odoo/runtime/patch_odoo.py | 10 ++++------ anybox/recipe/odoo/server.py | 11 ++++++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/anybox/recipe/odoo/runtime/patch_odoo.py b/anybox/recipe/odoo/runtime/patch_odoo.py index fc3fb8e8..ddbddd23 100644 --- a/anybox/recipe/odoo/runtime/patch_odoo.py +++ b/anybox/recipe/odoo/runtime/patch_odoo.py @@ -14,18 +14,16 @@ def do_patch(gevent_script_path): try: from odoo.service.server import PreforkServer, stripped_sys_argv + from odoo.release import version_info except ImportError: from openerp.service.server import PreforkServer, stripped_sys_argv + from openerp.release import version_info def long_polling_spawn(server): nargs = stripped_sys_argv() nargs[0] = gevent_script_path - try: # Add required gevent argument for Odoo 10.0 - from odoo.release import version_info - if version_info[0] >= 10: - nargs.insert(1, 'gevent') - except ImportError: - pass + if version_info[0] >= 10: + nargs.insert(1, 'gevent') popen = subprocess.Popen(nargs) server.long_polling_pid = popen.pid diff --git a/anybox/recipe/odoo/server.py b/anybox/recipe/odoo/server.py index e0f2529a..414417ac 100644 --- a/anybox/recipe/odoo/server.py +++ b/anybox/recipe/odoo/server.py @@ -516,14 +516,19 @@ def _install_startup_scripts(self): ('odoo_cron_worker', 'anybox.recipe.odoo.runtime.start_openerp', 'main'), - ('odoo-gevent', - 'odoo.cli', - 'main'), ('odoo_upgrader', 'anybox.recipe.odoo.runtime.upgrade', 'upgrade'), )) + if major_version(self.version_detected)[0] >= 10: + self.eggs_reqs.append( + ('odoo-gevent', 'odoo.cli', 'main'), + ) + else: + self.eggs_reqs.append( + ('odoo-gevent', 'openerp.cli', 'main'), + ) self._install_interpreter() main_script = self.options.get('script_name', 'start_' + self.name) From 0ed6d9e546a1c0fe7ef97e058e6c659ed4764f53 Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Fri, 23 Dec 2016 23:02:39 +0100 Subject: [PATCH 32/33] fix install-all parameter --- anybox/recipe/odoo/runtime/start_openerp.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/anybox/recipe/odoo/runtime/start_openerp.py b/anybox/recipe/odoo/runtime/start_openerp.py index ca2b5f3e..478f7a24 100644 --- a/anybox/recipe/odoo/runtime/start_openerp.py +++ b/anybox/recipe/odoo/runtime/start_openerp.py @@ -57,12 +57,16 @@ def main(starter, conf, version=None, just_test=False, if '--install-all' in sys.argv: sys.argv.remove('--install-all') - from openerp.tools import config + try: + from openerp.tools import config + from openerp.modules import get_modules + except ImportError: + from odoo.tools import config + from odoo.modules import get_modules # Maybe we should preparse config in all cases and therefore avoid # adding the '-c' on the fly ? # Still, cautious about pre-6.1 versions config.parse_config(['-c', conf]) - from openerp.modules import get_modules arguments.extend(('-i', ','.join(get_modules()))) insert_args(arguments) From d16dd518c9ab17dbb56fd32920c18e7cf22ae78d Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Tue, 3 Jan 2017 21:06:28 +0100 Subject: [PATCH 33/33] rename start_openerp.py to start_odoo.py --- anybox/recipe/odoo/runtime/__init__.py | 2 +- .../recipe/odoo/runtime/{start_openerp.py => start_odoo.py} | 4 ++-- .../recipe/odoo/runtime/{test_openerp.py => test_odoo.py} | 0 anybox/recipe/odoo/server.py | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) rename anybox/recipe/odoo/runtime/{start_openerp.py => start_odoo.py} (98%) rename anybox/recipe/odoo/runtime/{test_openerp.py => test_odoo.py} (100%) diff --git a/anybox/recipe/odoo/runtime/__init__.py b/anybox/recipe/odoo/runtime/__init__.py index f0135ebb..914ac068 100644 --- a/anybox/recipe/odoo/runtime/__init__.py +++ b/anybox/recipe/odoo/runtime/__init__.py @@ -7,7 +7,7 @@ * the ``session`` module features the supporting objects for "Odoo scripts" and the dedicated python interpreter. -* the ``start_openerp`` and ``test_openerp`` modules are the entry points for +* the ``start_odoo`` and ``test_odoo`` modules are the entry points for the main startup scripts. This architecture is meant in particular to provide stability and uniformity diff --git a/anybox/recipe/odoo/runtime/start_openerp.py b/anybox/recipe/odoo/runtime/start_odoo.py similarity index 98% rename from anybox/recipe/odoo/runtime/start_openerp.py rename to anybox/recipe/odoo/runtime/start_odoo.py index 478f7a24..068ec63a 100644 --- a/anybox/recipe/odoo/runtime/start_openerp.py +++ b/anybox/recipe/odoo/runtime/start_odoo.py @@ -1,8 +1,8 @@ """This module bridges the classical ``openerp-server`` as a console script. The :func:`main` function gets registered on the fly by the server recipe as -a console script entry point and used in particular for ``start_openerp`` and -``test_openerp``. +a console script entry point and used in particular for ``start_odoo`` and +``test_odoo``. Some version independence logic for the startup process also get bootstrapped from here. diff --git a/anybox/recipe/odoo/runtime/test_openerp.py b/anybox/recipe/odoo/runtime/test_odoo.py similarity index 100% rename from anybox/recipe/odoo/runtime/test_openerp.py rename to anybox/recipe/odoo/runtime/test_odoo.py diff --git a/anybox/recipe/odoo/server.py b/anybox/recipe/odoo/server.py index 414417ac..997e95b6 100644 --- a/anybox/recipe/odoo/server.py +++ b/anybox/recipe/odoo/server.py @@ -251,7 +251,7 @@ def _get_or_create_script(self, entry, name=None): return name, desc def _register_main_startup_script(self, qualified_name): - """Register main startup script, usually ``start_openerp`` for install. + """Register main startup script, usually ``start_odoo`` for install. """ desc = self._get_or_create_script('odoo_starter', name=qualified_name)[1] @@ -511,10 +511,10 @@ def _install_startup_scripts(self): # provide additional needed entry points for main start/test scripts self.eggs_reqs.extend(( ('odoo_starter', - 'anybox.recipe.odoo.runtime.start_openerp', + 'anybox.recipe.odoo.runtime.start_odoo', 'main'), ('odoo_cron_worker', - 'anybox.recipe.odoo.runtime.start_openerp', + 'anybox.recipe.odoo.runtime.start_odooo', 'main'), ('odoo_upgrader', 'anybox.recipe.odoo.runtime.upgrade',