Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support from Odoo 8.0 to odoo 10.0 #88

Merged
merged 41 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0e635b6
fix for odoo 10
archetipo Sep 12, 2016
8f59731
change openerp to odoo
archetipo Sep 12, 2016
43495a0
[FIX] path odoo/addons
archetipo Sep 27, 2016
a962919
[FIX] prj name odoo
archetipo Sep 27, 2016
b9b83b3
Revert "[FIX] prj name odoo"
archetipo Sep 27, 2016
3d7cdc0
Revert "[FIX] path odoo/addons"
archetipo Sep 27, 2016
9e77c39
[fix] openerp -> odoo
archetipo Sep 28, 2016
c24d04b
Revert "[fix] openerp -> odoo"
archetipo Sep 28, 2016
7f9f8f0
fix odoo-server
archetipo Sep 28, 2016
b215fd8
Revert "fix odoo-server"
archetipo Sep 28, 2016
e1a4faa
fix openerp-server -> odoo-bin
archetipo Sep 28, 2016
067945c
try to fix tests
archetipo Oct 4, 2016
6b89080
Fix Flake8
archetipo Oct 4, 2016
f184add
FIX test_parse_odoo_scripts
archetipo Oct 4, 2016
e5b0a9f
[IMP] Support server command of older versions
StefanRijnhart Oct 11, 2016
3ae3701
FIX flake 8
archetipo Oct 12, 2016
9607656
Maintain compatilbility with <10 version
legalsylvain Oct 16, 2016
47fcb65
[FIX] Add required gevent argument for Odoo 10.0
StefanRijnhart Oct 15, 2016
7a4fbce
[FIX] some remarks
archetipo Nov 18, 2016
44a2d00
manage some import to be compatible over odoo 8 and 10
Nov 29, 2016
21e1365
take care some of my reviews regarding odoo8 to 10 compatiblity
Nov 29, 2016
aaf7315
Merge pull request #4 from petrus-v/odoo10-compatibility
archetipo Nov 30, 2016
c0b860d
[FIX] Restore use of old registry in older releases
StefanRijnhart Dec 9, 2016
dce1dd2
Merge pull request #5 from StefanRijnhart/10.0-check_api_attr
archetipo Dec 13, 2016
c26750d
[FIX] Get an env with a particular context
StefanRijnhart Dec 13, 2016
43b6ac0
Merge pull request #6 from StefanRijnhart/10.0-fix_get_context
archetipo Dec 13, 2016
0170299
keep v8.0 compatibility while initiate db
Dec 15, 2016
94e30d9
[FIX] registry can't return new style model if there is no env
Dec 15, 2016
c502250
[buildbot] add builder for odoo8/odoo9 and fix builder 10 config
Dec 15, 2016
f7fc207
Merge pull request #7 from petrus-v/odoo8to10
archetipo Dec 16, 2016
44d0bed
Fix integration test, breaks compatibility with openerp 7.0
Dec 16, 2016
159b173
[buildbot config] add tag to easly differenciate a.r.odoo and a.r.ope…
Dec 16, 2016
91940c2
[integration test] as expect fix integration test for odoo 10.0
Dec 16, 2016
93d308e
Merge pull request #8 from petrus-v/odoo8to10
archetipo Dec 16, 2016
ea8d164
Using odoo 10.0 RegistryManager.get behavior change
Dec 21, 2016
9573201
Merge pull request #9 from petrus-v/odoo8to10
Dec 21, 2016
1d6f676
fix longpolling for odoo8
Dec 23, 2016
fb4cf16
Merge pull request #10 from petrus-v/odoo8to10
Dec 23, 2016
0ed6d9e
fix install-all parameter
Dec 23, 2016
d16dd51
rename start_openerp.py to start_odoo.py
Jan 3, 2017
9e0b6d1
Merge pull request #11 from petrus-v/odoo8to10
Jan 3, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ buildbot/develop-eggs/
buildbot/etc/
buildbot/parts/
doc/sphinx_build
.eggs
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@ Contributors:
* Sandy Carter
* Holger Brunn
* Leonardo Rochael Almeida
* Alessio Gerace
104 changes: 53 additions & 51 deletions anybox/recipe/odoo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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']
Expand Down Expand Up @@ -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[:3]
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'
Expand All @@ -275,7 +278,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]
Expand Down Expand Up @@ -305,7 +308,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)

Expand Down Expand Up @@ -379,7 +382,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. "
Expand Down Expand Up @@ -614,12 +617,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.
Expand All @@ -633,7 +636,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:
Expand Down Expand Up @@ -686,7 +689,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.
Expand Down Expand Up @@ -844,7 +847,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,
Expand Down Expand Up @@ -892,9 +894,9 @@ def retrieve_addons(self):
if subdir:
addons_dir = join(addons_dir, subdir)

manifest = os.path.join(addons_dir, '__openerp__.py')
manifest_pre_v6 = os.path.join(addons_dir, '__terp__.py')
if os.path.isfile(manifest) or os.path.isfile(manifest_pre_v6):
manifest = os.path.join(addons_dir, '__manifest__.py')
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 "
Expand All @@ -912,7 +914,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:
Expand Down Expand Up @@ -1020,7 +1022,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
Expand All @@ -1034,17 +1036,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()
Expand All @@ -1058,15 +1060,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
Expand All @@ -1093,8 +1095,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'):
Expand Down Expand Up @@ -1136,7 +1138,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.
Expand All @@ -1151,9 +1153,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
Expand All @@ -1177,8 +1179,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)

Expand Down Expand Up @@ -1377,10 +1379,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
Expand Down Expand Up @@ -1507,20 +1509,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

Expand Down Expand Up @@ -1576,7 +1578,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):
Expand Down Expand Up @@ -1605,7 +1607,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)

Expand Down Expand Up @@ -1647,7 +1649,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

Expand All @@ -1663,17 +1665,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')
egg_info_dir = join(self.odoo_dir, proj_name + '.egg-info')
if os.path.exists(egg_info_dir):
shutil.rmtree(egg_info_dir)

Expand All @@ -1694,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="
Expand Down
2 changes: 1 addition & 1 deletion anybox/recipe/odoo/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion anybox/recipe/odoo/runtime/patch_odoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@ 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
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
if version_info[0] >= 10:
nargs.insert(1, 'gevent')
popen = subprocess.Popen(nargs)
server.long_polling_pid = popen.pid

Expand Down
Loading