Skip to content

Commit

Permalink
Release 0.14.0 (2022-08-16)
Browse files Browse the repository at this point in the history
Added
-----

- Ability to automatically detect python for Odoo version via following options:
    - `odoo-helper install reinstall-venv --build-python auto`
    - `odoo-install --build-python auto`
- Ability to automatically build python of odoo version only if system python do not satisfy odoo requirements.
  For this reasone new option was added to following commands:
    - `odoo-helper install reinstall-venv --build-python-if-needed`
    - `odoo-install --build-python-if-needed`
- Add ability to enforce `odoo-helper fetch` clone repos with `--single-branch` options.
  This feature could be enabled via environment variable `ODOO_HELPER_FETCH_GIT_SINGLE_BRANCH`.
  This feature could be useful to reduce size of cloned repositories.
- Added ability to automatically update odoo-helper-scripts installed via debian package.

Changed
-------

- On module migration (during forwardport) automatically replace `related_sudo=` to `compute_sudo`
  for field definitions.

Deprecations
------------

- Option `odoo-install --openupgrade` is deprecated. It will raise error for odoo 14.0+.
  Starting from Odoo 14.0, openupgrade uses separate odoo addons to store migrations,
  instead of full copy of odoo.
  • Loading branch information
katyukha committed Aug 16, 2022
2 parents 9a3d21f + 839c8eb commit 446627e
Show file tree
Hide file tree
Showing 15 changed files with 232 additions and 95 deletions.
14 changes: 5 additions & 9 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: ubuntu:18.04
image: ubuntu:20.04

variables:
GIT_SUBMODULE_STRATEGY: recursive
Expand Down Expand Up @@ -96,10 +96,6 @@ tests:ubuntu:20.04:
image: ubuntu:20.04
<<: *tests-definition

tests:ubuntu:21.04:
image: ubuntu:21.04
<<: *tests-definition

tests:ubuntu:22.04:
image: ubuntu:22.04
<<: *tests-definition
Expand All @@ -118,9 +114,9 @@ tests:ubuntu:22.04:
build:package:tag:
<<: *build-package-base-def
script:
- bash scripts/build_packages.bash "${CI_COMMIT_TAG#v}"
- bash scripts/build_packages.bash
after_script:
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "build/odoo-helper-scripts_${CI_COMMIT_TAG#v}-ubuntu_all.deb" "${PACKAGE_REGISTRY_URL}/${CI_COMMIT_TAG#v}/odoo-helper-scripts_${CI_COMMIT_TAG#v}.deb"'
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "build/odoo-helper-scripts.deb" "${PACKAGE_REGISTRY_URL}/${CI_COMMIT_TAG#v}/odoo-helper-scripts_${CI_COMMIT_TAG#v}.deb"'
rules:
- if: $CI_COMMIT_TAG =~ /^v\d.*/

Expand All @@ -129,7 +125,7 @@ build:package:branch:dev:
script:
- bash scripts/build_packages.bash "${CI_COMMIT_REF_NAME}"
after_script:
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "build/odoo-helper-scripts_${CI_COMMIT_REF_NAME}-ubuntu_all.deb" "${PACKAGE_REGISTRY_URL}/${CI_COMMIT_REF_NAME}/odoo-helper-scripts_${CI_COMMIT_REF_NAME}.deb"'
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "build/odoo-helper-scripts.deb" "${PACKAGE_REGISTRY_URL}/${CI_COMMIT_REF_NAME}/odoo-helper-scripts_${CI_COMMIT_REF_NAME}.deb"'
when: manual
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
Expand All @@ -139,7 +135,7 @@ build:package:branch:master:
script:
- bash scripts/build_packages.bash "${CI_COMMIT_REF_NAME}"
after_script:
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "build/odoo-helper-scripts_${CI_COMMIT_REF_NAME}-ubuntu_all.deb" "${PACKAGE_REGISTRY_URL}/${CI_COMMIT_REF_NAME}/odoo-helper-scripts_${CI_COMMIT_REF_NAME}.deb"'
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "build/odoo-helper-scripts.deb" "${PACKAGE_REGISTRY_URL}/${CI_COMMIT_REF_NAME}/odoo-helper-scripts_${CI_COMMIT_REF_NAME}.deb"'
rules:
- if: $CI_COMMIT_BRANCH == "master"

Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Release Notes

## Release 0.14.0 (2022-08-16)

### Added

- Ability to automatically detect python for Odoo version via following options:
- `odoo-helper install reinstall-venv --build-python auto`
- `odoo-install --build-python auto`
- Ability to automatically build python of odoo version only if system python do not satisfy odoo requirements.
For this reasone new option was added to following commands:
- `odoo-helper install reinstall-venv --build-python-if-needed`
- `odoo-install --build-python-if-needed`
- Add ability to enforce `odoo-helper fetch` clone repos with `--single-branch` options.
This feature could be enabled via environment variable `ODOO_HELPER_FETCH_GIT_SINGLE_BRANCH`.
This feature could be useful to reduce size of cloned repositories.
- Added ability to automatically update odoo-helper-scripts installed via debian package.

### Changed

- On module migration (during forwardport) automatically replace `related_sudo=` to `compute_sudo`
for field definitions.


### Deprecations

- Option `odoo-install --openupgrade` is deprecated. It will raise error for odoo 14.0+.
Starting from Odoo 14.0, openupgrade uses separate odoo addons to store migrations,
instead of full copy of odoo.

---

## Release 0.13.0 (2022-06-25)

### Changed
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ The canonical source of odoo-helper-scripts is hosted on [GitLab](https://gitlab
- Including dependencies
- Semi-automatic upgrade when new version released
- installation from *git* repositories
- installation from *Mercurial* repositories (**experimental**)
- installation of python dependencies from [PyPI](pypi.python.org/pypi) or any [vcs supported by setuptools](https://setuptools.readthedocs.io/en/latest/setuptools.html?highlight=develop%20mode#dependencies-that-aren-t-in-pypi)
- automatically processing of [requirements.txt](https://pip.pypa.io/en/stable/user_guide/#requirements-files) files located inside repository root and addon directories.
- shortcuts that simplifies fetching addons from [OCA](https://github.com/OCA) or [github](https://github.com)
Expand Down
28 changes: 27 additions & 1 deletion bin/odoo-install
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function print_usage {
--odoo-repo <git repo> - git repository to get Odoo from. default: $ODOO_REPO
Used only if *download-archive* set to *off*
--ocb - Use [OCB (Odoo Community Backports)](https://github.com/OCA/OCB) fork
--ou|--openupgrade - Use [OpenUpgrade](https://github.com/OCA/OpenUpgrade) fork
--ou|--openupgrade - [Deprecated] Use [OpenUpgrade](https://github.com/OCA/OpenUpgrade) fork
--odoo-version <odoo version> - odoo version to install. default: $ODOO_VERSION
-b|--odoo-branch <branch> - specify odoo branch to install. default: $ODOO_BRANCH
Normaly it is same as odoo version, but if You want to install odoo
Expand All @@ -96,6 +96,8 @@ function print_usage {
This option is used only if --download-archive is 'off'
Default: $CLONE_SINGLE_BRANCH
--build-python <ver> - build custom python for specified version
'auto' could be specified to automatically guess correct version.
--build-python-if-needed - Automatically detect if it is necessary to build custom python.
--build-python-optimize - Apply '--enable-optimizations' for python build.
This could take a while.
--build-python-sqlite3 - Apply --enable-loadable-sqlite-extensions
Expand Down Expand Up @@ -135,6 +137,12 @@ function parse_options {
exit 0;
fi

# Set this as variable, because it's processing requires
# that all other options already handled
local build_python_if_needed;
local is_openupgrade_install;

# Parse options
while [[ $# -gt 0 ]]
do
local key="$1";
Expand All @@ -151,6 +159,7 @@ function parse_options {
ODOO_REPO="https://github.com/OCA/OCB";
;;
--ou|--openupgrade)
is_openupgrade_install=1;
ODOO_REPO="https://github.com/OCA/OpenUpgrade";
;;
--odoo-version)
Expand Down Expand Up @@ -186,6 +195,9 @@ function parse_options {
ODOO_BUILD_PYTHON_VERSION=$2;
shift;
;;
--build-python-if-needed)
build_python_if_needed=1;
;;
--build-python-optimize)
ODOO_BUILD_PYTHON_OPTIMIZE=1;
;;
Expand Down Expand Up @@ -249,6 +261,20 @@ function parse_options {
esac
shift
done

if [ -n "$build_python_if_needed" ] && ! odoo_ensure_python_version; then
# TODO: Possibly this have to be done on install_odoo func.
# Especially, in case when we decide to automatically install
# system dependencies during odoo installation.
echoe -e "${BLUEC}Enabling automatic build of python...${NC}";
ODOO_BUILD_PYTHON_VERSION=auto;
fi

if [ -n "$is_openupgrade_install" ] && [ "$(odoo_get_major_version)" -gt 13 ]; then
echoe -e "${REDC}ERROR${NC}:${BLUEC}This option is not allowed of Odoo 14.0 and above, because starting from Odoo 14 openupgrade repo contains only migration scripts...${NC}";
exit 2;
fi

}

function install_odoo {
Expand Down
1 change: 0 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ If you have any routine operation that you would like to automate with odoo-help
- Including dependencies
- Semi-automatic upgrade when new version released
- installation from *git* repositories
- installation from *Mercurial* repositories (**experimental**)
- installation of python dependencies from [PyPI](pypi.python.org/pypi) or any [vcs supported by setuptools](https://setuptools.readthedocs.io/en/latest/setuptools.html?highlight=develop%20mode#dependencies-that-aren-t-in-pypi)
- automatically processing of [requirements.txt](https://pip.pypa.io/en/stable/user_guide/#requirements-files) files located inside repository root and addon directories.
- shortcuts that simplifies fetching addons from [OCA](https://github.com/OCA) or [github](https://github.com)
Expand Down
4 changes: 2 additions & 2 deletions lib/db.bash
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ function odoo_db_backup {
shift;
;;
-h|--help|help)
echo "$usage";
echoe -e "$usage";
return 0;
;;
-*)
Expand Down Expand Up @@ -613,7 +613,7 @@ function odoo_db_backup_all {
shift;
;;
-h|--help|help)
echo "$usage";
echoe -e "$usage";
return 0;
;;
-*)
Expand Down
24 changes: 23 additions & 1 deletion lib/fetch.bash
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ function fetch_get_repo_path {
#
# fetch_clone_repo <url> <dest> [branch]
function fetch_clone_repo_git {
# TODO: Refactor this function to use arrays for command options
local repo_url=$1; shift;
local repo_dest=$1; shift;

Expand All @@ -262,6 +263,18 @@ function fetch_clone_repo_git {
echoe -e "${BLUEC}Use ${YELLOWC}gitlab-ci-token${BLUEC} for auth to repository ${YELLOWC}${CI_JOB_TOKEN_GIT_HOST}${NC}";
fi

if [ -n "$ODOO_HELPER_FETCH_GIT_SINGLE_BRANCH" ]; then
if [ -z "$repo_branch_opt" ]; then
# In case of single branch we have to clone only single branch,
# thus we have to determine this branch before we clone repo.
repo_branch_opt="-b $ODOO_VERSION";
git_clone_opt="$git_clone_opt $repo_branch_opt";
fi
git_clone_opt="$git_clone_opt --single-branch";
fi

# TODO: Add support for cloning repos with depth=1

[ -z "$VERBOSE" ] && git_clone_opt="$git_clone_opt -q "
git_cmd="git $extra_git_opt clone --recurse-submodules $git_clone_opt $repo_url $repo_dest";
if ! eval "$git_cmd"; then
Expand Down Expand Up @@ -379,7 +392,7 @@ function fetch_module {
# TODO: simplify this function. remove unneccessary options
local usage="
Fetch Odoo addons from various sources
(including git, mercurial, Odoo Apps)
(including git, Odoo Apps)
Usage:
$SCRIPT_NAME fetch -r|--repo <git repository> [-m|--module <odoo module name>] [-n|--name <repo name>] [-b|--branch <git branch>]
Expand All @@ -400,6 +413,15 @@ function fetch_module {
--requirements <file> - path to requirements file to fetch required modules
NOTE: requirements file must end with newline.
Configuration via environment variables:
- ODOO_HELPER_FETCH_GIT_SINGLE_BRANCH - if set then odoo-helper
will use --single-branch
option to clone repo
- ODOO_HELPER_FETCH_PIP_AUTO_REQUIREMENTS - if set, then odoo-helper
will process requirements.auto.txt
file in repositories/modules
Note that in one call only one option of
(--repo, --github, --oca, --odoo-app)
have to be present in one line.
Expand Down
35 changes: 34 additions & 1 deletion lib/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -682,9 +682,31 @@ function install_system_prerequirements {
}


function install_build_python_guess_version {
if [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -lt 11 ]; then
echo "2.7.18";
elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 11 ]; then
echo "3.7.13";
elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 12 ]; then
echo "3.7.13";
elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 13 ]; then
echo "3.8.13";
elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 14 ]; then
echo "3.8.13";
elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 15 ]; then
echo "3.8.13";
else
echoe -e "${REDC}ERROR${NC}: Automatic detection of python version for odoo ${ODOO_VERSION} is not supported!";
return 1;
fi
}

# Download and build specified python version
function install_build_python {
local python_version="$1"
if [[ "${python_version}" == auto ]]; then
python_version=$(install_build_python_guess_version);
fi
local python_download_link="https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tgz";
local python_download_dir="$DOWNLOADS_DIR";
local python_download_path="$python_download_dir/python-${python_version}.tgz";
Expand All @@ -707,6 +729,7 @@ function install_build_python {
return 1
fi

echoe -e "${BLUEC}Downloading python version ${YELLOWC}${python_version}${BLUEC}...${NC}"
if ! wget -q -T 15 -O "$python_download_path" "$python_download_link"; then
echoe -e "${REDC}ERROR${NC}: Cannot download Odoo from ${YELLOWC}${python_download_link}${NC}."
echoe -e "Remove broken download (if it is exists) ${YELLOWC}${python_download_path}${NC}."
Expand Down Expand Up @@ -1163,6 +1186,8 @@ function odoo_run_setup_py {

if [ "$(odoo_get_major_version)" -gt 10 ]; then
# We have to replace suds-jurko with suds-py3 to make it installable.
# Note, that we do it here, because it is mentioned in setup.py,
# thus it cannot be updated in standard way.
sed -i 's/suds-jurko/suds-py3/g' "$ODOO_PATH/setup.py";
fi

Expand Down Expand Up @@ -1210,7 +1235,9 @@ function install_reinstall_venv {
Default: lts
--no-backup - do not backup virtualenv
--build-python <version> - Build custom version of python for
this virtual environment
this virtual environment.
'auto' could be specified to automatically guess correct version.
--build-python-if-needed - Automatically detect if it is necessary to build custom python.
--build-python-optimize - Apply --enable-optimizations to python build.
This could take a while.
--build-python-sqlite3 - Apply --enable-loadable-sqlite-extensions
Expand All @@ -1235,6 +1262,11 @@ function install_reinstall_venv {
ODOO_BUILD_PYTHON_VERSION=$2;
shift;
;;
--build-python-if-needed)
if odoo_ensure_python_version; then
ODOO_BUILD_PYTHON_VERSION=auto;
fi
;;
--build-python-optimize)
ODOO_BUILD_PYTHON_OPTIMIZE=1;
;;
Expand Down Expand Up @@ -1285,6 +1317,7 @@ function install_reinstall_venv {

# Update python dependencies for addons
addons_update_py_deps;
echoe -e "${GREENC}OK${BLUEC}: ${YELLOWC}virtualenv${BLUEC} reinstalled successfully!${NC}";
}

function install_reinstall_odoo {
Expand Down
27 changes: 27 additions & 0 deletions lib/odoo.bash
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,33 @@ function odoo_get_python_interpreter {
check_command "$python_version";
}

# Check if system (current) python satisfies odoo requirements
function odoo_ensure_python_version {
if [ -z "$ODOO_VERSION" ]; then
return 1; # Odoo version is not specified
fi
local python_interpreter;
python_interpreter=$(odoo_get_python_interpreter);
if [ -z "$python_interpreter" ]; then
return 2; # Python interpreter is not available
fi

if [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 11 ]; then
${python_interpreter} -c "import sys; assert (3, 6) <= sys.version_info < (3, 9);" > /dev/null 2>&1;
elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 12 ]; then
${python_interpreter} -c "import sys; assert (3, 6) <= sys.version_info < (3, 9);" > /dev/null 2>&1;
elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 13 ]; then
${python_interpreter} -c "import sys; assert (3, 6) <= sys.version_info < (3, 10);" > /dev/null 2>&1;
elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 14 ]; then
${python_interpreter} -c "import sys; assert (3, 6) <= sys.version_info < (3, 10);" > /dev/null 2>&1;
elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 15 ]; then
${python_interpreter} -c "import sys; assert (3, 7) <= sys.version_info < (3, 11);";
else
echoe -e "${REDC}ERROR${NC}: Automatic detection of python version for odoo ${ODOO_VERSION} is not supported!";
return 1;
fi
}

function odoo_recompute_stored_fields {
local usage="
Recompute stored fields
Expand Down
8 changes: 8 additions & 0 deletions lib/pylib/ci_fw_postfixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
r"\.phantom_js\(",
".browser_js(",
"Replace calls to 'phantom_js' with 'browser_js'."),
("replace",
r"related_sudo=(?P<value>(True|False))",
"compute_sudo=\g<value>",
"Replace related_sudo to compute_sudo"),
],
'.xml': [
("replace",
Expand All @@ -64,6 +68,10 @@
r"\.phantom_js\(",
".browser_js(",
"Replace calls to 'phantom_js' with 'browser_js'."),
("replace",
r"related_sudo=(?P<value>(True|False))",
"compute_sudo=\g<value>",
"Replace related_sudo to compute_sudo"),
],
}

Expand Down
Loading

0 comments on commit 446627e

Please sign in to comment.