diff --git a/.gitignore b/.gitignore index 2bf95fd..2116d5e 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,8 @@ doc/itpp* doc/odoo* script/OCA* odoo +odoo*/OCA_OpenUpgrade +odoo*/odoo_documentation-user image_db get-poetry.py artifacts @@ -39,7 +41,10 @@ pyproject.toml .odoo-version .poetry-version .python-version +.python-odoo-version requirements.txt requirement/ignore_requirements.txt screenshots screencasts +script/todo/todo_override.json +.erplibre.error.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d417d8..9589de6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Added - Script for hardening the installation +- Support Odoo versions 12.0 to 18.0 +- Separate ERPLibre python installation from Odoo python with .venv.erplibre and .venv.odoo18 +- Implement auto-installation with TODO.py ## [1.6.0] - 2025-04-25 diff --git a/Makefile b/Makefile index 38e7856..63e5824 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ SHELL := /bin/bash -LOG_FILE := ./.venv/make_test.log +LOG_FILE := ./.venv.$(cat ".erplibre-version" | xargs)/make_test.log ############# # General # ############# @@ -123,7 +123,7 @@ open_terminal: ############## .PHONY: open_selenium open_selenium: - ./.venv/bin/python ./script/selenium/web_login.py + ./.venv.erplibre/bin/python ./script/selenium/web_login.py ############ # format # @@ -134,42 +134,42 @@ format: .PHONY: format_code_generator format_code_generator: - .venv/bin/isort --profile black -l 79 ./addons/TechnoLibre_odoo-code-generator/ + .venv.erplibre/bin/isort --profile black -l 79 ./addons/TechnoLibre_odoo-code-generator/ ./script/maintenance/black.sh ./addons/TechnoLibre_odoo-code-generator/ ./script/maintenance/prettier_xml.sh ./addons/TechnoLibre_odoo-code-generator/ .PHONY: format_erplibre_addons format_erplibre_addons: - .venv/bin/isort --profile black -l 79 ./addons/ERPLibre_erplibre_addons/ + .venv.erplibre/bin/isort --profile black -l 79 ./addons/ERPLibre_erplibre_addons/ ./script/maintenance/black.sh ./addons/ERPLibre_erplibre_addons/ ./script/maintenance/prettier_xml.sh ./addons/ERPLibre_erplibre_addons/ - .venv/bin/isort --profile black -l 79 ./addons/ERPLibre_erplibre_theme_addons/ + .venv.erplibre/bin/isort --profile black -l 79 ./addons/ERPLibre_erplibre_theme_addons/ ./script/maintenance/black.sh ./addons/ERPLibre_erplibre_theme_addons/ #./script/maintenance/prettier_xml.sh ./addons/ERPLibre_erplibre_theme_addons/ .PHONY: format_supported_addons format_supported_addons: - .venv/bin/isort --profile black -l 79 ./addons/MathBenTech_erplibre-family-management/ + .venv.erplibre/bin/isort --profile black -l 79 ./addons/MathBenTech_erplibre-family-management/ ./script/maintenance/black.sh ./addons/MathBenTech_erplibre-family-management/ #./script/maintenance/prettier_xml.sh ./addons/MathBenTech_erplibre-family-management/ - .venv/bin/isort --profile black -l 79 ./addons/MathBenTech_odoo-business-spending-management-quebec-canada/ + .venv.erplibre/bin/isort --profile black -l 79 ./addons/MathBenTech_odoo-business-spending-management-quebec-canada/ ./script/maintenance/black.sh ./addons/MathBenTech_odoo-business-spending-management-quebec-canada/ #./script/maintenance/prettier_xml.sh ./addons/MathBenTech_erplibre-family-management/ .PHONY: format_code_generator_template format_code_generator_template: - .venv/bin/isort --profile black -l 79 ./addons/TechnoLibre_odoo-code-generator-template/ + .venv.erplibre/bin/isort --profile black -l 79 ./addons/TechnoLibre_odoo-code-generator-template/ ./script/maintenance/black.sh ./addons/TechnoLibre_odoo-code-generator-template/ #./script/maintenance/prettier_xml.sh ./addons/TechnoLibre_odoo-code-generator-template/ .PHONY: format_script format_script: - #.venv/bin/isort --profile black -l 79 ./script/ --gitignore + #.venv.erplibre/bin/isort --profile black -l 79 ./script/ --gitignore ./script/maintenance/black.sh ./script/ .PHONY: format_script_isort_only format_script_isort_only: - .venv/bin/isort --profile black -l 79 ./script/ --gitignore + .venv.erplibre/bin/isort --profile black -l 79 ./script/ --gitignore ######### # log # @@ -210,7 +210,7 @@ repo_configure_group_code_generator: # Show git status for all repo .PHONY: repo_show_status repo_show_status: - ./.venv/repo forall -pc "git status -s" + .venv.erplibre/bin/repo forall -pc "git status -s" # Show divergence between actual repository and production manifest .PHONY: repo_diff_manifest_production diff --git a/README.md b/README.md index 20797c7..ae913bc 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # ERPLibre ERPLibre is a CRM/ERP platform including automated installation, maintenance, and development of open source modules of -the Odoo community version. It is a "soft-fork" of the Odoo Community Edition (OCE), meaning it aims at contributing back -upstream. +the Odoo community version. It is a "soft-fork" of the Odoo Community Edition (OCE), meaning it aims at contributing +back upstream. It is based on a set of production-ready modules, supported by the Odoo Community Association (OCA) and an ecosystem of specialized companies. This solution ensures digital sovereignty in a local environment while integrating pre-trained Generative Transformers (GPT), bringing an additional dimension to data management and automation. @@ -11,32 +11,57 @@ Follow us on Mastodon : https://fosstodon.org/@erplibre # Installation -Select a guide to install your environment. - -## Easy install on Ubuntu or Debian using Docker +## Easy installation on Ubuntu or Debian using Docker This has been tested in Debian 12 and Ubuntu 24.04 LTS. -**Note** : This is meant for a test environment, on a local network or similar environment not directly exposed to the Internet. +**Note** : This is meant for a test environment, on a local network or similar environment not directly exposed to the +Internet. 1. Make sure Docker and nginx web server are installed:
-```sudo apt install docker docker-compose nginx``` + ```sudo apt install docker docker-compose nginx``` 1. Get the latest ERPLibre Docker compose file:
-```wget https://raw.githubusercontent.com/ERPLibre/ERPLibre/v1.6.0/docker-compose.yml``` + ```wget https://raw.githubusercontent.com/ERPLibre/ERPLibre/v1.6.0/docker-compose.yml``` 1. Install and run ERPLibre with Docker running as a daemon (web server):
-```sudo docker-compose up -d``` + ```sudo docker-compose up -d``` 1. Open the final installation step at this web page :
-```http://[server IP]:8069```
-![Capture du 2024-11-05 08-34-45](https://github.com/user-attachments/assets/7c6295b6-cc95-462d-822c-3ff72b772155) -1. Finish the installation by providing a database name, email and password. then click on **Create Database**. Depending on your system resources **this may take more than 2 minutes without feedback !** Check your browser loading indicator. + ```http://[server IP]:8069```
+ ![odoo_first_installation.png](doc/image/odoo_first_installation.png) +1. Finish the installation by providing a database name, email and password. then click on **Create Database**. + Depending on your system resources **this may take more than 2 minutes without feedback !** Check your browser + loading indicator. 1. Next, the web page will reload itself, and you should see the Applications list in ERPLibre:
-![2024-11-05_09-54](https://github.com/user-attachments/assets/1742c4a9-da96-466b-9c17-35eb5ca786ff) -You can now personalize your ERPLibre installation. + ![odoo_application_list.png](doc/image/odoo_application_list.png) + + You can now personalize your ERPLibre installation. For more information, read [Docker guide](./docker/README.md). ## Install from source code +### Automated installation + +For Debian/Ubuntu + +```bash +sudo apt install make python +``` + +Clone the project: + +```bash +git clone https://github.com/ERPLibre/ERPLibre.git +cd ERPLibre +``` + +Follow the instruction on the following script, it will try to detect your environment. + +```bash +./script/todo/todo.py +``` + +### Manually + Into Ubuntu, minimal dependency: ```bash @@ -81,6 +106,9 @@ Ready to execute: make run ``` +### For Windows + +For Windows, read [WINDOWS_INSTALLATION.md](doc/WINDOWS_INSTALLATION.md) ## Discover guide @@ -94,26 +122,6 @@ make run [Guide to run ERPLibre in development environment](./doc/DEVELOPMENT.md). -### Pycharm - -First open - -```bash -make pycharm_open -``` - -Close it, and configure - -```bash -make pycharm_configure -``` - -Open it - -```bash -make pycharm_open -``` - # Execution [Guide to run ERPLibre with different case](./doc/RUN.md). diff --git a/TODO.md b/TODO.md index 85364d6..4866dce 100644 --- a/TODO.md +++ b/TODO.md @@ -6,7 +6,7 @@ devops_erplibre need sshpass ## Simplify push tag For RELEASE.md, replace next value by a script to select all remote by manifest file. Actually, need to push manually all different remote. -> ./.venv/repo forall -pc "git push ERPLibre --tags" +> .venv.erplibre/bin/repo forall -pc "git push ERPLibre --tags" ## Funding - Add funding for MathBenTech and TechnoLibre diff --git a/conf/git_manifest.csv b/conf/git_manifest.csv new file mode 100644 index 0000000..e70dab6 --- /dev/null +++ b/conf/git_manifest.csv @@ -0,0 +1,2 @@ +"filepath" +manifest/git_manifest_erplibre.xml diff --git a/conf/git_manifest_odoo.csv b/conf/git_manifest_odoo.csv new file mode 100644 index 0000000..09a81f1 --- /dev/null +++ b/conf/git_manifest_odoo.csv @@ -0,0 +1,5 @@ +"filepath" +manifest/git_manifest_erplibre.xml +manifest/git_manifest_erplibre_extra.xml +manifest/git_manifest_erplibre_odoo.xml +manifest/git_manifest_erplibre_odoo_dev.xml diff --git a/conf/make.code_generator.Makefile b/conf/make.code_generator.Makefile index e42d59f..37b8462 100644 --- a/conf/make.code_generator.Makefile +++ b/conf/make.code_generator.Makefile @@ -288,39 +288,39 @@ test_code_generator_demo_mariadb_sql_example_1: .PHONY: test_addons_code_generator test_addons_code_generator: - ./.venv/bin/coverage erase + ./.venv.erplibre/bin/coverage erase ./odoo_bin.sh db --drop --database test_addons_code_generator # TODO missing test in code_generator ./test.sh --dev cg -d test_addons_code_generator --db-filter test_addons_code_generator -i code_generator - ./.venv/bin/coverage combine -a - ./.venv/bin/coverage report -m --include="addons/TechnoLibre_odoo-code-generator/*" - ./.venv/bin/coverage html --include="addons/TechnoLibre_odoo-code-generator/*" - ./.venv/bin/coverage json --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage combine -a + ./.venv.erplibre/bin/coverage report -m --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage html --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage json --include="addons/TechnoLibre_odoo-code-generator/*" # run: make open_test_coverage .PHONY: test_addons_code_generator_code_generator test_addons_code_generator_code_generator: # TODO this test only generation, not test - ./.venv/bin/coverage erase + ./.venv.erplibre/bin/coverage erase ./script/database/db_restore.py --database test_addons_code_generator_code_generator ./test.sh --dev cg -d test_addons_code_generator_code_generator --db-filter test_addons_code_generator_code_generator -i code_generator_code_generator - ./.venv/bin/coverage combine -a - ./.venv/bin/coverage report -m --include="addons/TechnoLibre_odoo-code-generator/*" - ./.venv/bin/coverage html --include="addons/TechnoLibre_odoo-code-generator/*" - ./.venv/bin/coverage json --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage combine -a + ./.venv.erplibre/bin/coverage report -m --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage html --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage json --include="addons/TechnoLibre_odoo-code-generator/*" # run: make open_test_coverage .PHONY: test_addons_code_generator_template_code_generator test_addons_code_generator_template_code_generator: # TODO this test only generation, not test - ./.venv/bin/coverage erase + ./.venv.erplibre/bin/coverage erase ./script/database/db_restore.py --database test_addons_code_generator_template_code_generator ./test.sh --dev cg -d test_addons_code_generator_template_code_generator --db-filter test_addons_code_generator_template_code_generator -i code_generator ./test.sh --dev cg -d test_addons_code_generator_template_code_generator --db-filter test_addons_code_generator_template_code_generator -i code_generator_template_code_generator - ./.venv/bin/coverage combine -a - ./.venv/bin/coverage report -m --include="addons/TechnoLibre_odoo-code-generator/*" - ./.venv/bin/coverage html --include="addons/TechnoLibre_odoo-code-generator/*" - ./.venv/bin/coverage json --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage combine -a + ./.venv.erplibre/bin/coverage report -m --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage html --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage json --include="addons/TechnoLibre_odoo-code-generator/*" # run: make open_test_coverage # generate config repo code_generator diff --git a/conf/make.documentation.Makefile b/conf/make.documentation.Makefile index f58cf68..ab2569f 100644 --- a/conf/make.documentation.Makefile +++ b/conf/make.documentation.Makefile @@ -31,7 +31,7 @@ open_doc_all: # documentation dev .PHONY: doc_dev doc_dev: - source ./.venv/bin/activate && make -C doc/itpp-labs_odoo-development/docs html || exit 1 + source ./.venv.erplibre/bin/activate && make -C doc/itpp-labs_odoo-development/docs html || exit 1 .PHONY: open_doc_dev open_doc_dev: @@ -44,7 +44,7 @@ doc_clean_dev: # documentation migration .PHONY: doc_migration doc_migration: - source ./.venv/bin/activate && make -C doc/itpp-labs_odoo-port-docs/docs html || exit 1 + source ./.venv.erplibre/bin/activate && make -C doc/itpp-labs_odoo-port-docs/docs html || exit 1 .PHONY: open_doc_migration open_doc_migration: @@ -57,7 +57,7 @@ doc_clean_migration: # documentation test .PHONY: doc_test doc_test: - source ./.venv/bin/activate && make -C doc/itpp-labs_odoo-test-docs/doc-src html || exit 1 + source ./.venv.erplibre/bin/activate && make -C doc/itpp-labs_odoo-test-docs/doc-src html || exit 1 .PHONY: open_doc_test open_doc_test: @@ -71,7 +71,7 @@ doc_clean_test: .PHONY: doc_user doc_user: ln -sf ../../odoo/odoo ./doc/odoo_documentation-user/odoo - source ./.venv/bin/activate && make -C doc/odoo_documentation-user html || exit 1 + source ./.venv.erplibre/bin/activate && make -C doc/odoo_documentation-user html || exit 1 .PHONY: open_doc_user open_doc_user: @@ -84,4 +84,4 @@ doc_clean_user: # documentation markdown .PHONY: doc_markdown doc_markdown: - ./.venv/bin/mmg --verbose --yes ./doc/CODE_GENERATOR.base.md + ./.venv.erplibre/bin/mmg --verbose --yes ./doc/CODE_GENERATOR.base.md diff --git a/conf/make.image_db.Makefile b/conf/make.image_db.Makefile index 9922be9..8dc7b76 100644 --- a/conf/make.image_db.Makefile +++ b/conf/make.image_db.Makefile @@ -15,21 +15,21 @@ image_db_create_erplibre_code_generator: image_db_create_all_parallel: ./script/database/db_restore.py --clean_cache echo "Search in-existing module" - ./.venv/bin/python3 ./script/database/image_db.py --check_addons_exist + ./.venv.erplibre/bin/python3 ./script/database/image_db.py --check_addons_exist echo "Create Image DB" - ./.venv/bin/python3 ./script/database/image_db.py --generate_bash_cmd_parallel | bash + ./.venv.erplibre/bin/python3 ./script/database/image_db.py --generate_bash_cmd_parallel | bash ./script/database/db_restore.py --clean_cache #./script/make.sh image_db_create_test_website_attachments .PHONY: image_db_list_data image_db_list_data: - ./.venv/bin/python3 ./script/database/image_db.py --generate_bash_cmd_parallel - #./.venv/bin/python3 ./script/database/image_db.py --generate_bash_cmd_parallel --odoo_version 12.0 + ./.venv.erplibre/bin/python3 ./script/database/image_db.py --generate_bash_cmd_parallel + #./.venv.erplibre/bin/python3 ./script/database/image_db.py --generate_bash_cmd_parallel --odoo_version 12.0 .PHONY: image_db_list image_db_list: - ./.venv/bin/python3 ./script/database/image_db.py --show_list_only - #./.venv/bin/python3 ./script/database/image_db.py --generate_bash_cmd_parallel --odoo_version 12.0 + ./.venv.erplibre/bin/python3 ./script/database/image_db.py --show_list_only + #./.venv.erplibre/bin/python3 ./script/database/image_db.py --generate_bash_cmd_parallel --odoo_version 12.0 .PHONY: image_db_create_test_website_attachments image_db_create_test_website_attachments: diff --git a/conf/make.installation.Makefile b/conf/make.installation.Makefile index ce2e6fa..2be2f45 100644 --- a/conf/make.installation.Makefile +++ b/conf/make.installation.Makefile @@ -11,13 +11,40 @@ install_dev: # ./script/install/install_locally_dev.sh ./script/version/update_env_version.py --install_dev +.PHONY: install_odoo_18 +install_odoo_18: + ./script/version/update_env_version.py --erplibre_version odoo18.0_python3.12.10 --install_dev + +.PHONY: switch_odoo_18 +switch_odoo_18: + ./script/version/update_env_version.py --erplibre_version odoo18.0_python3.12.10 --switch + ./script/make.sh config_gen_all + +.PHONY: install_odoo_17 +install_odoo_17: + ./script/version/update_env_version.py --erplibre_version odoo17.0_python3.10.18 --install_dev + +.PHONY: switch_odoo_17 +switch_odoo_17: + ./script/version/update_env_version.py --erplibre_version odoo17.0_python3.10.18 --switch + ./script/make.sh config_gen_all + .PHONY: install_odoo_16 install_odoo_16: - ./script/version/update_env_version.py --erplibre_version odoo16.0_python3.10.14 --install_dev + ./script/version/update_env_version.py --erplibre_version odoo16.0_python3.10.18 --install_dev .PHONY: switch_odoo_16 switch_odoo_16: - ./script/version/update_env_version.py --erplibre_version odoo16.0_python3.10.14 --switch + ./script/version/update_env_version.py --erplibre_version odoo16.0_python3.10.18 --switch + ./script/make.sh config_gen_all + +.PHONY: install_odoo_15 +install_odoo_15: + ./script/version/update_env_version.py --erplibre_version odoo15.0_python3.8.20 --install_dev + +.PHONY: switch_odoo_15 +switch_odoo_15: + ./script/version/update_env_version.py --erplibre_version odoo15.0_python3.8.20 --switch ./script/make.sh config_gen_all .PHONY: install_odoo_14 @@ -29,6 +56,15 @@ switch_odoo_14: ./script/version/update_env_version.py --erplibre_version odoo14.0_python3.8.20 --switch ./script/make.sh config_gen_all +.PHONY: install_odoo_13 +install_odoo_13: + ./script/version/update_env_version.py --erplibre_version odoo13.0_python3.7.17 --install_dev + +.PHONY: switch_odoo_13 +switch_odoo_13: + ./script/version/update_env_version.py --erplibre_version odoo13.0_python3.7.17 --switch + ./script/make.sh config_gen_all + .PHONY: install_odoo_12 install_odoo_12: ./script/version/update_env_version.py --erplibre_version odoo12.0_python3.7.17 --install_dev @@ -40,17 +76,19 @@ switch_odoo_12: .PHONY: install_odoo_all_version install_odoo_all_version: - ./script/make.sh install_odoo_12 - ./script/make.sh install_odoo_14 + ./script/make.sh install_odoo_18 + ./script/make.sh install_odoo_17 ./script/make.sh install_odoo_16 + ./script/make.sh install_odoo_15 + ./script/make.sh install_odoo_14 + ./script/make.sh install_odoo_13 + ./script/make.sh install_odoo_12 .PHONY: install_odoo_all_version_dev install_odoo_all_version_dev: echo "Open Pycharm, close it before install Odoo and reopen at the end" pycharm . - ./script/make.sh install_odoo_12 - ./script/make.sh install_odoo_14 - ./script/make.sh install_odoo_16 + ./script/make.sh install_odoo_all_version #.PHONY: install_update_odoo #install_update_odoo: diff --git a/conf/make.test.Makefile b/conf/make.test.Makefile index 8d996a6..2e86f25 100644 --- a/conf/make.test.Makefile +++ b/conf/make.test.Makefile @@ -2,7 +2,7 @@ # TEST # ######## -# TODO load specific test file : ./run.sh -d test_file --log-level=test --test-enable --stop-after-init --test-file ./.venv/test.py +# TODO load specific test file : ./run.sh -d test_file --log-level=test --test-enable --stop-after-init --test-file ./.venv.erplibre/test.py .PHONY: open_test_coverage open_test_coverage: @@ -48,14 +48,14 @@ test_full_fast_coverage: ./script/make.sh clean # Need to create a BD to create cache _cache_erplibre_base ./script/database/db_restore.py --database test - ./.venv/bin/coverage erase + ./.venv.erplibre/bin/coverage erase ./script/test/run_parallel_test.py --coverage # TODO This test is broken in parallel #./script/make.sh test_coverage_code_generator_hello_world - ./.venv/bin/coverage combine -a - ./.venv/bin/coverage report -m --include="addons/TechnoLibre_odoo-code-generator/*" - ./.venv/bin/coverage html --include="addons/TechnoLibre_odoo-code-generator/*" - ./.venv/bin/coverage json --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage combine -a + ./.venv.erplibre/bin/coverage report -m --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage html --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage json --include="addons/TechnoLibre_odoo-code-generator/*" # run: make open_test_coverage @@ -64,12 +64,12 @@ test_cg_demo: ./script/make.sh clean # Need to create a BD to create cache _cache_erplibre_base ./script/database/db_restore.py --database test - ./.venv/bin/coverage erase + ./.venv.erplibre/bin/coverage erase ./script/addons/coverage_install_addons_dev.sh test code_generator_demo - ./.venv/bin/coverage combine -a - ./.venv/bin/coverage report -m --include="addons/TechnoLibre_odoo-code-generator/*" - ./.venv/bin/coverage html --include="addons/TechnoLibre_odoo-code-generator/*" - ./.venv/bin/coverage json --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage combine -a + ./.venv.erplibre/bin/coverage report -m --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage html --include="addons/TechnoLibre_odoo-code-generator/*" + ./.venv.erplibre/bin/coverage json --include="addons/TechnoLibre_odoo-code-generator/*" .PHONY: test_base test_base: @@ -102,20 +102,20 @@ test_installation_demo: ############### .PHONY: test_addons_sale test_addons_sale: - ./.venv/bin/coverage erase + ./.venv.erplibre/bin/coverage erase ./odoo_bin.sh db --drop --database test_addons_sale ./test.sh -d test_addons_sale --db-filter test_addons_sale -i sale - ./.venv/bin/coverage combine -a - ./.venv/bin/coverage report -m - ./.venv/bin/coverage html - ./.venv/bin/coverage json + ./.venv.erplibre/bin/coverage combine -a + ./.venv.erplibre/bin/coverage report -m + ./.venv.erplibre/bin/coverage html + ./.venv.erplibre/bin/coverage json .PHONY: test_addons_helpdesk test_addons_helpdesk: - ./.venv/bin/coverage erase + ./.venv.erplibre/bin/coverage erase ./odoo_bin.sh db --drop --database test_addons_helpdesk ./test.sh -d test_addons_helpdesk --db-filter test_addons_helpdesk -i helpdesk_mgmt - ./.venv/bin/coverage combine -a - ./.venv/bin/coverage report -m - ./.venv/bin/coverage html - ./.venv/bin/coverage json \ No newline at end of file + ./.venv.erplibre/bin/coverage combine -a + ./.venv.erplibre/bin/coverage report -m + ./.venv.erplibre/bin/coverage html + ./.venv.erplibre/bin/coverage json \ No newline at end of file diff --git a/conf/module_list_image_db_odoo.json b/conf/module_list_image_db_odoo.json index 801f241..a9fdbea 100644 --- a/conf/module_list_image_db_odoo.json +++ b/conf/module_list_image_db_odoo.json @@ -239,6 +239,24 @@ } ] }, + "odoo13.0_base": { + "base": "", + "disable": false, + "image_list": [ + { + "module": [ + "auth_user_case_insensitive", + "auto_backup", + "disable_odoo_online", + "fetchmail_notify_error_to_sender", + "mail_debrand", + "remove_odoo_enterprise", + "web_responsive", + "web_timeline" + ] + } + ] + }, "odoo14.0_base": { "base": "", "disable": false, @@ -427,6 +445,34 @@ } ] }, + "odoo15.0_base": { + "base": "", + "disable": false, + "image_list": [ + { + "module": [ + "auth_user_case_insensitive", + "auto_backup", + "disable_odoo_online", + "mail_debrand", + "remove_odoo_enterprise", + "web_responsive", + "web_timeline", + "partner_firstname", + "web_search_with_and", + "web_listview_range_select", + "web_dialog_size", + "password_security", + "web_refresher", + "date_range", + "partner_contact_access_link", + "auditlog", + "queue_job", + "web_advanced_search" + ] + } + ] + }, "odoo16.0_base": { "base": "", "disable": false, @@ -639,5 +685,56 @@ ] } ] + }, + "odoo17.0_base": { + "base": "", + "disable": false, + "image_list": [ + { + "module": [ + "auth_user_case_insensitive", + "auto_backup", + "disable_odoo_online", + "mail_debrand", + "remove_odoo_enterprise", + "web_responsive", + "web_timeline", + "server_action_mass_edit", + "partner_firstname", + "web_search_with_and", + "web_dialog_size", + "password_security", + "web_refresher", + "date_range", + "partner_contact_access_link", + "auditlog", + "queue_job" + ] + } + ] + }, + "odoo18.0_base": { + "base": "", + "disable": false, + "image_list": [ + { + "module": [ + "auth_user_case_insensitive", + "disable_odoo_online", + "remove_odoo_enterprise", + "web_responsive", + "web_timeline", + "server_action_mass_edit", + "partner_firstname", + "web_search_with_and", + "web_dialog_size", + "password_security", + "web_refresher", + "date_range", + "partner_contact_access_link", + "queue_job" + ] + } + ] } } diff --git a/conf/pycharm_exclude_folder.txt b/conf/pycharm_exclude_folder.txt index 14cf1b3..bfaaa99 100644 --- a/conf/pycharm_exclude_folder.txt +++ b/conf/pycharm_exclude_folder.txt @@ -11,6 +11,7 @@ cache htmlcov node_modules .venv +.venv.erplibre odoo screencasts screenshots diff --git a/conf/python-erplibre-venv b/conf/python-erplibre-venv new file mode 100644 index 0000000..48a0b46 --- /dev/null +++ b/conf/python-erplibre-venv @@ -0,0 +1 @@ +.venv.erplibre \ No newline at end of file diff --git a/conf/python-erplibre-version b/conf/python-erplibre-version new file mode 100644 index 0000000..d367df0 --- /dev/null +++ b/conf/python-erplibre-version @@ -0,0 +1 @@ +3.12.10 \ No newline at end of file diff --git a/conf/supported_version_erplibre.json b/conf/supported_version_erplibre.json index c3486bf..c3e634e 100644 --- a/conf/supported_version_erplibre.json +++ b/conf/supported_version_erplibre.json @@ -2,18 +2,48 @@ "odoo12.0_python3.7.17": { "odoo_version": "12.0", "python_version": "3.7.17", - "poetry_version": "1.5.0" + "poetry_version": "1.5.0", + "is_deprecated": true, + "note": "Deprecated" + }, + "odoo13.0_python3.7.17": { + "odoo_version": "13.0", + "python_version": "3.7.17", + "poetry_version": "1.5.0", + "is_deprecated": true, + "note": "Deprecated" }, "odoo14.0_python3.8.20": { "odoo_version": "14.0", "python_version": "3.8.20", - "poetry_version": "1.5.0" + "poetry_version": "1.5.0", + "is_deprecated": true, + "note": "Deprecated" }, - "odoo16.0_python3.10.14": { + "odoo15.0_python3.8.20": { + "odoo_version": "15.0", + "python_version": "3.8.20", + "poetry_version": "1.8.3", + "is_deprecated": true, + "note": "Deprecated" + }, + "odoo16.0_python3.10.18": { "odoo_version": "16.0", - "python_version": "3.10.14", + "python_version": "3.10.18", "poetry_version": "1.8.3", "default": true, "note": "Official support ERPLibre 1.6.0" + }, + "odoo17.0_python3.10.18": { + "odoo_version": "17.0", + "python_version": "3.10.18", + "poetry_version": "1.8.3", + "note": "New GUI" + }, + "odoo18.0_python3.12.10": { + "odoo_version": "18.0", + "python_version": "3.12.10", + "poetry_version": "2.1.3", + "note": "Last version" } } diff --git a/doc/DEVELOPMENT.md b/doc/DEVELOPMENT.md index 5d8c700..4e89348 100644 --- a/doc/DEVELOPMENT.md +++ b/doc/DEVELOPMENT.md @@ -198,7 +198,7 @@ rm -r ~/.local/share/Odoo/filestore/database_name ## Create module scaffold ```bash -source ./.venv/bin/activate +source ./.venv.erplibre/bin/activate python odoo/odoo-bin scaffold MODULE_NAME addons/REPO_NAME/ ``` @@ -212,7 +212,7 @@ Read GIT_REPO.md to understand how changer version. ## Python version -Your actual version is in file .python-version. Use script `./script/version/change_python_version.sh 3.7.16` to change +Your actual version is in file .python-odoo-version. Use script `./script/version/change_python_version.sh 3.7.16` to change to version 3.7.16 . Run the installation, `make install_dev`. @@ -228,17 +228,9 @@ When you need to change python 3.7.17 to 3.8.10, do : ```bash rm -r .venv make install_dev -./.venv/bin/poetry lock --no-update +./.venv.$(cat ".erplibre-version" | xargs)/bin/poetry lock --no-update ``` -And update file script/install/install_locally.sh - -`ln -fs ${EL_HOME_ODOO}/odoo ${EL_HOME}/.venv/lib/python3.7/site-packages/` - -to - -`ln -fs ${EL_HOME_ODOO}/odoo ${EL_HOME}/.venv/lib/python3.8/site-packages/` - # Pull request ## Show all pull requests from organization diff --git a/doc/GIT_REPO.md b/doc/GIT_REPO.md index 27a5fa7..c8c017c 100644 --- a/doc/GIT_REPO.md +++ b/doc/GIT_REPO.md @@ -8,21 +8,21 @@ licence [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0.html). ## Setup repo ```bash -curl https://storage.googleapis.com/git-repo-downloads/repo > ./.venv/repo +curl https://storage.googleapis.com/git-repo-downloads/repo > .venv.erplibre/bin/repo ``` ## prod ```bash -./.venv/repo init -u https://github.com/ERPLibre/ERPLibre -b master -./.venv/repo sync +.venv.erplibre/bin/repo init -u https://github.com/ERPLibre/ERPLibre -b master +.venv.erplibre/bin/repo sync -c -j $(nproc --all) ``` ## dev ```bash -./.venv/repo init -u https://github.com/ERPLibre/ERPLibre -b 12.0_repo -m ./manifest/default.dev.xml -./.venv/repo sync +.venv.erplibre/bin/repo init -u https://github.com/ERPLibre/ERPLibre -b 12.0_repo -m ./manifest/default.dev.xml +.venv.erplibre/bin/repo sync -c -j $(nproc --all) ``` ## local dev @@ -32,8 +32,8 @@ curl https://storage.googleapis.com/git-repo-downloads/repo > ./.venv/repo ```bash git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose & -./.venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m ./manifest/default.dev.xml -./.venv/repo sync -m ./manifest/default.dev.xml +.venv.erplibre/bin/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m ./manifest/default.dev.xml +.venv.erplibre/bin/repo sync -c -j $(nproc --all) -m ./manifest/default.dev.xml ``` # Create Manifest @@ -48,7 +48,7 @@ It freezes all repo, from dev to prod. This will add revision git hash in the manifest. ```bash -./.venv/repo manifest -r -o ./default.xml +.venv.erplibre/bin/repo manifest -r -o ./default.xml ``` Commit. @@ -63,21 +63,21 @@ When dev contains specific revision with default revision, you need to replace d keep specific version: ```bash -./script/git/git_merge_repo_manifest.py --input1 ./manifest/default.dev.xml --input2 ./default.xml --output ./manifest/default.staged.xml +./script/git/git_merge_repo_manifest.py --input "./manifest/default.dev.xml;./default.xml" --output ./manifest/default.staged.xml git commit -am "Updated manifest/default.staged.xml" git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose & -./.venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m ./manifest/default.staged.xml -./.venv/repo sync -m ./manifest/default.staged.xml +.venv.erplibre/bin/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m ./manifest/default.staged.xml +.venv.erplibre/bin/repo sync -c -j $(nproc --all) -m ./manifest/default.staged.xml -./.venv/repo manifest -r -o ./default.xml +.venv.erplibre/bin/repo manifest -r -o ./default.xml ``` ## Create a dev version ```bash -./.venv/repo manifest -o ./manifest/default.dev.xml +.venv.erplibre/bin/repo manifest -o ./manifest/default.dev.xml ``` Commit. @@ -91,19 +91,19 @@ git commit -am "[#ticket] subject: short sentence" ### Search all repos with a specific branch name ```bash -./.venv/repo forall -pc "git branch -a|grep BRANCH" +.venv.erplibre/bin/repo forall -pc "git branch -a|grep BRANCH" ``` ### Search missing branch in all repos ```bash -./.venv/repo forall -pc 'git branch -a|(grep /BRANCH$||echo "no match")|grep "no match"' +.venv.erplibre/bin/repo forall -pc 'git branch -a|(grep /BRANCH$||echo "no match")|grep "no match"' ``` ### Search changed file in all repos ```bash -./.venv/repo forall -pc "git status -s" +.venv.erplibre/bin/repo forall -pc "git status -s" ``` ### Clean all @@ -111,7 +111,7 @@ git commit -am "[#ticket] subject: short sentence" Before cleaning, check changed file in all repos. ```bash -./.venv/repo forall -pc "git status -s" +.venv.erplibre/bin/repo forall -pc "git status -s" ``` Check the changed branch, and push changed if needed. diff --git a/doc/MIGRATION.md b/doc/MIGRATION.md index 4c74e2e..0ad0ddb 100644 --- a/doc/MIGRATION.md +++ b/doc/MIGRATION.md @@ -52,7 +52,7 @@ Execute migration with OpenUpgrade. ```bash make config_gen_migration -./.venv/bin/python ./script/OCA_OpenUpgrade/odoo-bin -c ./config.conf --no-http --update all --stop-after-init -d BD +./.venv.erplibre/bin/python ./script/OCA_OpenUpgrade/odoo-bin -c ./config.conf --no-http --update all --stop-after-init -d BD ``` ## Migration Odoo 13 to Odoo 14 diff --git a/doc/RELEASE.md b/doc/RELEASE.md index caeb74f..c433f83 100644 --- a/doc/RELEASE.md +++ b/doc/RELEASE.md @@ -7,7 +7,7 @@ A guide on how to generate a release. Before the cleaning, check if existing file isn't committed, not pushed or in stash. ```bash -./.venv/repo forall -pc "git stash list" +.venv.erplibre/bin/repo forall -pc "git stash list" ./script/git/git_show_code_diff_repo_manifest.py ``` @@ -102,7 +102,7 @@ To test it, you need to clean caches and install it: Generate production manifest and freeze all repos versions. ```bash -./.venv/repo manifest -r -o ./default.xml +.venv.erplibre/bin/repo manifest -r -o ./default.xml ``` Update ERPLIBRE_VERSION variable in [env_var.sh](../env_var.sh), [Dockerfile.prod](../docker/Dockerfile.prod.pkg) @@ -129,7 +129,7 @@ Understand differences from last release: git diff v#.#.#..HEAD # All repo -./.venv/repo forall -pc "git diff ERPLibre/v#.#.#..HEAD" +.venv.erplibre/bin/repo forall -pc "git diff ERPLibre/v#.#.#..HEAD" ``` Simplification tools: @@ -169,7 +169,7 @@ git tag v#.#.# # Push your tags git push --tags # Add tags for all repo -./.venv/repo forall -pc "git tag ERPLibre/v#.#.#" +.venv.erplibre/bin/repo forall -pc "git tag ERPLibre/v#.#.#" make tag_push_all ``` diff --git a/doc/image/odoo_application_list.png b/doc/image/odoo_application_list.png new file mode 100644 index 0000000..426915b Binary files /dev/null and b/doc/image/odoo_application_list.png differ diff --git a/doc/image/odoo_first_installation.png b/doc/image/odoo_first_installation.png new file mode 100644 index 0000000..1aeef9a Binary files /dev/null and b/doc/image/odoo_first_installation.png differ diff --git a/docker/Dockerfile.prod.pkg b/docker/Dockerfile.prod.pkg index 83fd927..8e5afcf 100644 --- a/docker/Dockerfile.prod.pkg +++ b/docker/Dockerfile.prod.pkg @@ -35,12 +35,16 @@ RUN cd ; mkdir -p .bin/ && \ RUN cd $ODOO_PREFIX && \ ls -lha /ERPLibre && \ - python -m venv .venv + python -m venv .venv.$ERPLIBRE_VERSION RUN cd $ODOO_PREFIX && \ ls -lha /ERPLibre && \ - curl https://storage.googleapis.com/git-repo-downloads/repo > ./.venv/repo && \ - chmod +x ./.venv/repo + python -m venv .venv.erplibre + +RUN cd $ODOO_PREFIX && \ + ls -lha /ERPLibre && \ + curl https://storage.googleapis.com/git-repo-downloads/repo > .venv.erplibre/bin/repo && \ + chmod +x .venv.erplibre/bin/repo RUN cd $ODOO_PREFIX && \ ls -lha /ERPLibre && \ @@ -59,10 +63,10 @@ RUN apt update && \ RUN cd $ODOO_PREFIX && \ ls -lha /ERPLibre && \ echo "${ERPLIBRE_VERSION}" && \ - ./.venv/bin/pip install --upgrade pip && git branch && ls . -lha && \ - ./.venv/bin/pip install "poetry==${POETRY_VERSION}" && \ - ./.venv/bin/poetry --version && \ - ./.venv/bin/poetry install + ./.venv.$(cat ".erplibre-version" | xargs)/bin/pip install --upgrade pip && git branch && ls . -lha && \ + ./.venv.$(cat ".erplibre-version" | xargs)/bin/pip install "poetry==${POETRY_VERSION}" && \ + ./.venv.$(cat ".erplibre-version" | xargs)/bin/poetry --version && \ + ./.venv.$(cat ".erplibre-version" | xargs)/bin/poetry install # Install local npm RUN cd $ODOO_PREFIX && \ diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 08bef83..847d272 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -12,7 +12,7 @@ then echo "my repo" $(git rev-parse --abbrev-ref HEAD) repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m default.dev.xml - repo sync + repo sync -c -j $(nproc --all) # After sync, terminate the git checkout. We don't need graceful kill as we don't do commit on the git repo during the operation. kill -9 $GIT_PID @@ -79,12 +79,12 @@ case "$1" in if [[ "${STOP_BEFORE_INIT}" == "True" ]] ; then sleep 999999 fi - /ERPLibre/.venv/bin/python ./docker/wait-for-psql.py ${DB_ARGS[@]} --timeout=30 + /ERPLibre/.venv.$(cat ".erplibre-version" | xargs)/bin/python ./docker/wait-for-psql.py ${DB_ARGS[@]} --timeout=30 if [[ "${UPDATE_ALL_DB}" == "True" ]] ; then # --stop-after-init - exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf -u all -d "${DB_NAME}" + exec ./.venv.$(cat ".erplibre-version" | xargs)/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf -u all -d "${DB_NAME}" else - exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf + exec ./.venv.$(cat ".erplibre-version" | xargs)/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf fi fi ;; @@ -93,11 +93,11 @@ case "$1" in if [[ "${STOP_BEFORE_INIT}" == "True" ]] ; then sleep 999999 fi - /ERPLibre/.venv/bin/python ./docker/wait-for-psql.py ${DB_ARGS[@]} --timeout=30 + /ERPLibre/.venv.$(cat ".erplibre-version" | xargs)/bin/python ./docker/wait-for-psql.py ${DB_ARGS[@]} --timeout=30 if [[ "${UPDATE_ALL_DB}" == "True" ]] ; then - exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf -u all -d "${DB_NAME}" + exec ./.venv.$(cat ".erplibre-version" | xargs)/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf -u all -d "${DB_NAME}" else - exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf + exec ./.venv.$(cat ".erplibre-version" | xargs)/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf fi ;; *) diff --git a/env_var.sh b/env_var.sh index 2fc09a5..4c766b9 100755 --- a/env_var.sh +++ b/env_var.sh @@ -5,10 +5,11 @@ ERPLIBRE_VERSION="1.6.0" EL_USER="erplibre" EL_HOME="/${EL_USER}" EL_HOME_ERPLIBRE="${EL_HOME}/erplibre" -EL_HOME_ODOO="${EL_HOME_ERPLIBRE}/odoo" +EL_HOME_ODOO="${EL_HOME_ERPLIBRE}/odoo$(cat ".odoo-version" | xargs)/odoo" EL_ODOO_VERSION=$(cat ".odoo-version" | xargs) EL_POETRY_VERSION=$(cat ".poetry-version" | xargs) -EL_PYTHON_VERSION=$(cat ".python-version" | xargs) +EL_PYTHON_ODOO_VERSION=$(cat ".python-odoo-version" | xargs) +EL_PYTHON_ERPLIBRE_VERSION=$(cat "./conf/python-erplibre-version" | xargs) EL_ERPLIBRE_VERSION=$(cat ".erplibre-version" | xargs) # The default port where this Odoo instance will run under (provided you use the command -c in the terminal) # Set to true if you want to install it, false if you don't need it or have it already installed. @@ -26,4 +27,4 @@ EL_INSTALL_NGINX="False" EL_WEBSITE_NAME="localhost" EL_GITHUB_TOKEN="" EL_MANIFEST_PROD="./default.xml" -EL_MANIFEST_DEV="./manifest/default.dev.xml" +EL_MANIFEST_DEV="./manifest/git_manifest_erplibre.xml" diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..ff04bef --- /dev/null +++ b/install.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +./script/todo/todo.py diff --git a/odoo_bin.sh b/odoo_bin.sh index 4d7e308..12aeb29 100755 --- a/odoo_bin.sh +++ b/odoo_bin.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash -source ./.venv/bin/activate +# This is required to change environment for the running Odoo +source ./.venv.$(< .erplibre-version)/bin/activate ODOO_PATH="$(pwd)/odoo$(< .odoo-version)" #export PATH=$ODOO_PATH:$PATH diff --git a/run.sh b/run.sh index 4c49124..f715249 100755 --- a/run.sh +++ b/run.sh @@ -2,6 +2,7 @@ Red='\033[0;31m' # Red Color_Off='\033[0m' # Text Reset +# Search by default local configuration CONFIG_PATH="./config.conf" ORIGIN_CONFIG_PATH=CONFIG_PATH if [ ! -f "${CONFIG_PATH}" ]; then diff --git a/script/database/image_db.py b/script/database/image_db.py index 72e4603..d205239 100755 --- a/script/database/image_db.py +++ b/script/database/image_db.py @@ -16,7 +16,7 @@ logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO")) _logger = logging.getLogger(__name__) -PYTHON_BIN = ".venv/bin/python3" +PYTHON_BIN = ".venv.erplibre/bin/python3" IMAGE_DB_BIN = f"{PYTHON_BIN} ./script/database/image_db.py" diff --git a/script/database/restore_mariadb_sql_example_1.sh b/script/database/restore_mariadb_sql_example_1.sh index 9670726..4ebf95a 100755 --- a/script/database/restore_mariadb_sql_example_1.sh +++ b/script/database/restore_mariadb_sql_example_1.sh @@ -26,4 +26,4 @@ echo "Import SQL file" mysql -u organization -porganization mariadb_sql_example_1 < ${SQL_PATH} echo "Fix SQL in database" -./.venv/bin/python ./script/database/fix_mariadb_sql_example_1.py +./.venv.erplibre/bin/python ./script/database/fix_mariadb_sql_example_1.py diff --git a/script/docker/docker_build.sh b/script/docker/docker_build.sh index 287fcf4..af1d116 100755 --- a/script/docker/docker_build.sh +++ b/script/docker/docker_build.sh @@ -6,7 +6,7 @@ Color_Off='\033[0m' # Text Reset ERPLIBRE_IMAGE_NAME=$(cat .erplibre-semver-version|xargs) ERPLIBRE_VERSION_MAIN=$(cat .erplibre-version|xargs) ODOO_VERSION=$(cat .odoo-version|xargs) -PYTHON_VERSION=$(cat .python-version|xargs) +PYTHON_VERSION=$(cat .python-odoo-version|xargs) POETRY_VERSION=$(cat .poetry-version|xargs) IS_DEBIAN_BOOKWORM=true diff --git a/script/docker/docker_repo_show_status.sh b/script/docker/docker_repo_show_status.sh index a080881..3837cac 100755 --- a/script/docker/docker_repo_show_status.sh +++ b/script/docker/docker_repo_show_status.sh @@ -9,7 +9,7 @@ BASENAME="${BASENAME,,}" docker exec -u root -ti ${BASENAME}-ERPLibre-1 /bin/bash -c "\ cd /ERPLibre; \ -./.venv/repo forall -pc 'git status -s'; \ +.venv.erplibre/bin/repo forall -pc 'git status -s'; \ echo ''; \ git status -s; \ " @@ -18,7 +18,7 @@ retVal=$? if [[ $retVal -ne 0 ]]; then docker exec -u root -ti ${BASENAME}_ERPLibre_1 /bin/bash -c "\ cd /ERPLibre; \ - ./.venv/repo forall -pc 'git status -s'; \ + .venv.erplibre/bin/repo forall -pc 'git status -s'; \ echo ''; \ git status -s; \ " diff --git a/script/generate_config.sh b/script/generate_config.sh index b6586fe..5a54cfb 100755 --- a/script/generate_config.sh +++ b/script/generate_config.sh @@ -4,7 +4,7 @@ EL_USER=${USER} EL_HOME=$PWD -EL_HOME_ODOO="${EL_HOME}/odoo" +EL_HOME_ODOO="${EL_HOME}/odoo${EL_ODOO_VERSION}/odoo" #EL_PORT="8069" #EL_LONGPOLLING_PORT="8072" #EL_SUPERADMIN="admin" @@ -26,11 +26,7 @@ printf "longpolling_port = ${EL_LONGPOLLING_PORT}\n" >> "${EL_CONFIG_FILE}" printf "addons_path = ${EL_HOME_ODOO}/addons,${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/addons," >> "${EL_CONFIG_FILE}" if [[ ${EL_MINIMAL_ADDONS} = "False" ]]; then - printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/CybroOdoo_CybroAddons," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/CybroOdoo_OpenHRMS," >> "${EL_CONFIG_FILE}" - printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/ERPLibre_erplibre_addons," >> "${EL_CONFIG_FILE}" - printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/MathBenTech_development," >> "${EL_CONFIG_FILE}" - printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/MathBenTech_odoo-business-spending-management-quebec-canada," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_account-analytic," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_account-budgeting," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_account-closing," >> "${EL_CONFIG_FILE}" @@ -44,6 +40,7 @@ if [[ ${EL_MINIMAL_ADDONS} = "False" ]]; then printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_account-reconcile," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_apps-store," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_bank-payment," >> "${EL_CONFIG_FILE}" + printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_bank-payment-alternative," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_bank-statement-import," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_brand," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_business-requirement," >> "${EL_CONFIG_FILE}" @@ -58,10 +55,12 @@ if [[ ${EL_MINIMAL_ADDONS} = "False" ]]; then printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_contract," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_credit-control," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_crm," >> "${EL_CONFIG_FILE}" + printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_crowdfunding," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_currency," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_data-protection," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_ddmrp," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_delivery-carrier," >> "${EL_CONFIG_FILE}" + printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_dms," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_donation," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_e-commerce," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_edi," >> "${EL_CONFIG_FILE}" @@ -75,6 +74,7 @@ if [[ ${EL_MINIMAL_ADDONS} = "False" ]]; then printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_interface-github," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_knowledge," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_l10n-canada," >> "${EL_CONFIG_FILE}" + printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_mail," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_maintenance," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_management-system," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_manufacture," >> "${EL_CONFIG_FILE}" @@ -101,14 +101,11 @@ if [[ ${EL_MINIMAL_ADDONS} = "False" ]]; then printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_server-backend," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_server-brand," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_server-env," >> "${EL_CONFIG_FILE}" - printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_server-tools," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_server-ux," >> "${EL_CONFIG_FILE}" - printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_shift-planning," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_social," >> "${EL_CONFIG_FILE}" + printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_stock-logistics-putaway," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_stock-logistics-warehouse," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_storage," >> "${EL_CONFIG_FILE}" - printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_survey," >> "${EL_CONFIG_FILE}" - printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_timesheet," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_vertical-association," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_vertical-hotel," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_vertical-isp," >> "${EL_CONFIG_FILE}" @@ -119,14 +116,10 @@ if [[ ${EL_MINIMAL_ADDONS} = "False" ]]; then printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OCA_wms," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/OmniaGit_odooplm," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/camptocamp_odoo-cloud-platform," >> "${EL_CONFIG_FILE}" - printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/cetmix_cetmix-tower," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/dhongu_deltatech," >> "${EL_CONFIG_FILE}" - printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/it-projects-llc_saas-addons," >> "${EL_CONFIG_FILE}" - printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/muk-it_muk_web," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/novacode-nl_odoo-formio," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/odoomates_odooapps," >> "${EL_CONFIG_FILE}" printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/openeducat_openeducat_erp," >> "${EL_CONFIG_FILE}" - printf "${EL_HOME}/addons.odoo${EL_ODOO_VERSION}/tegin_medical-fhir," >> "${EL_CONFIG_FILE}" fi printf "\n" >> "${EL_CONFIG_FILE}" @@ -140,6 +133,6 @@ fi # Update and fix the config.conf # Fix only the configuration if installation is done -if [ -f "./.venv/bin/activate" ] && [ -f "./odoo/odoo-bin" ]; then +if [ -f "./.venv.$(< .erplibre-version)/bin/activate" ] && [ -f "./odoo$(< .odoo-version)/odoo/odoo-bin" ]; then make config_update fi diff --git a/script/git/git_merge_repo_manifest.py b/script/git/git_merge_repo_manifest.py index 7266181..3f4940e 100755 --- a/script/git/git_merge_repo_manifest.py +++ b/script/git/git_merge_repo_manifest.py @@ -4,6 +4,7 @@ import argparse import copy +import csv import logging import os import sys @@ -18,6 +19,14 @@ from script.git.git_tool import GitTool _logger = logging.getLogger(__name__) +DEFAULT_PATH_MANIFEST_CONF = os.path.join("conf", "git_manifest.csv") +DEFAULT_PATH_MANIFEST_ODOO_CONF = os.path.join("conf", "git_manifest_odoo.csv") +DEFAULT_PATH_MANIFEST_PRIVATE_CONF = os.path.join( + "private", "default_git_manifest.csv" +) +DEFAULT_PATH_INSTALLED_ODOO_VERSION = os.path.join(".repo", "installed_odoo_version.txt") + + def get_config(): """Parse command line arguments, extracting the config file name, returning the union of config file and command line arguments @@ -32,16 +41,18 @@ def get_config(): """, ) parser.add_argument( - "--input1", required=True, help="First manifest to merge into input2." + "--input", + help="First manifest to merge into input2. Second manifest, overwrite by input1.", + ) + parser.add_argument("--output", default=".repo/local_manifests/erplibre_manifest.xml", help="Output of new manifest") + parser.add_argument( + "--att_revision_only", + action="store_true", + help="Output of new manifest", ) parser.add_argument( - "--input2", required=True, help="Second manifest, overwrite by input1." + "--with_OCA", action="store_true", help="Add OCA manifest" ) - parser.add_argument( - "--output", required=True, help="Output of new manifest" - ) - # parser.add_argument('--clear', action="store_true", - # help="Create a new manifest and clear old configuration.") args = parser.parse_args() return args @@ -50,36 +61,122 @@ def main(): config = get_config() git_tool = GitTool() - ( - dct_remote_1, - dct_project_1, - default_remote_1, - ) = git_tool.get_manifest_xml_info(filename=config.input1, add_root=True) - ( - dct_remote_2, - dct_project_2, - default_remote_2, - ) = git_tool.get_manifest_xml_info(filename=config.input2, add_root=True) + lst_input = config.input + if not lst_input: + lst_input = [] + if config.with_OCA: + append_file_path_manifest( + lst_input, DEFAULT_PATH_MANIFEST_ODOO_CONF + ) + if os.path.exists(".odoo-version"): + with open(".odoo-version", "r") as f: + odoo_version = f.readline() + if odoo_version: + path_manifest_odoo_version = os.path.join( + "manifest", f"git_manifest_odoo{odoo_version}.xml" + ) + if os.path.exists(path_manifest_odoo_version): + lst_input.append(path_manifest_odoo_version) + else: + print( + f"ERROR: {path_manifest_odoo_version} does not exist" + ) + path_manifest_odoo_version = os.path.join( + "manifest", f"git_manifest_odoo{odoo_version}_dev.xml" + ) + if os.path.exists(path_manifest_odoo_version): + lst_input.append(path_manifest_odoo_version) - dct_remote_3 = copy.deepcopy(dct_remote_2) - dct_project_3 = copy.deepcopy(dct_project_2) + if os.path.exists(DEFAULT_PATH_INSTALLED_ODOO_VERSION): + with open(DEFAULT_PATH_INSTALLED_ODOO_VERSION, "r") as f: + lst_installed_odoo_version = [a.strip() for a in f.readlines()] + if lst_installed_odoo_version: + for installed_odoo_version in lst_installed_odoo_version: + path_manifest_odoo_version = os.path.join( + "manifest", f"git_manifest_{installed_odoo_version}.xml" + ) + if os.path.exists(path_manifest_odoo_version): + lst_input.append(path_manifest_odoo_version) + else: + print( + f"ERROR: {path_manifest_odoo_version} does not exist" + ) + path_manifest_odoo_version = os.path.join( + "manifest", f"git_manifest_{installed_odoo_version}_dev.xml" + ) + if os.path.exists(path_manifest_odoo_version): + lst_input.append(path_manifest_odoo_version) - for key, value in dct_project_1.items(): - revision = value.get("@revision") - if revision: - dct_project_3[key]["@revision"] = revision else: - dct_project_3[key]["@upstream"] = "12.0" - dct_project_3[key]["@dest-branch"] = "12.0" + append_file_path_manifest(lst_input, DEFAULT_PATH_MANIFEST_CONF) + append_file_path_manifest( + lst_input, DEFAULT_PATH_MANIFEST_PRIVATE_CONF + ) + + dct_remote_total = {} + dct_project_total = {} + default_remote_total = None + + # Be sure all input is unique + lst_input = list(set(lst_input)) + + for index, input_path in enumerate(lst_input): + ( + dct_remote, + dct_project, + default_remote, + ) = git_tool.get_manifest_xml_info(filename=input_path, add_root=True) + + # Support multiple version odoo + dct_project_copy = dct_project + dct_project = {} + for key, value in dct_project_copy.items(): + new_key = f"{key}+{value.get('@path')}" + dct_project[new_key] = value + + if len(lst_input) == 1: + # Only 1 input, same output + dct_remote_total = dct_remote + dct_project_total = dct_project + break + elif not index: + # Preparation to accumulate data + dct_remote_total = copy.deepcopy(dct_remote) + dct_project_total = copy.deepcopy(dct_project) + continue + for key, value in dct_project.items(): + if key in dct_project_total.keys(): + if config.att_revision_only: + revision = value.get("@revision") + if revision: + dct_project_total[key]["@revision"] = revision + else: + dct_project_total[key].update(value) + else: + dct_project_total[key] = copy.deepcopy(value) + + for key, value in dct_remote.items(): + if key in dct_remote_total.keys(): + dct_remote_total[key].update(value) + else: + dct_remote_total[key] = copy.deepcopy(value) - # Update origin to new repo git_tool.generate_repo_manifest( - dct_remote=dct_remote_3, - dct_project=dct_project_3, + dct_remote=dct_remote_total, + dct_project=dct_project_total, output=config.output, - default_remote=default_remote_2, + default_remote=default_remote_total, ) +def append_file_path_manifest(lst_input, path_manifest): + if os.path.exists(path_manifest): + with open(path_manifest, "r") as f: + csv_file = csv.DictReader(f) + for row in csv_file: + filepath = row.get("filepath") + lst_input.append(filepath) + + if __name__ == "__main__": main() diff --git a/script/git/git_tool.py b/script/git/git_tool.py index 6c69f92..0fdeab8 100644 --- a/script/git/git_tool.py +++ b/script/git/git_tool.py @@ -3,6 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) import os +import pathlib import webbrowser from collections import OrderedDict from typing import List @@ -20,8 +21,6 @@ CST_EL_GITHUB_TOKEN = "EL_GITHUB_TOKEN" DEFAULT_PROJECT_NAME = "ERPLibre" DEFAULT_WEBSITE = "erplibre.ca" DEFAULT_REMOTE_URL = "https://github.com/ERPLibre/ERPLibre.git" -with open(".odoo-version", "r") as f: - DEFAULT_BRANCH = f.readline() class Struct(object): @@ -44,7 +43,17 @@ class GitTool: @property def default_branch(self): - return DEFAULT_BRANCH + return self.odoo_version + + @property + def odoo_version(self): + with open(".odoo-version", "r") as f: + default_branch = f.readline() + return default_branch + + @property + def odoo_version_long(self): + return f"odoo{self.odoo_version}" @staticmethod def get_url(url: str) -> object: @@ -270,7 +279,12 @@ class GitTool: xml_as_string = xml.read() xml_dict = xmltodict.parse(xml_as_string) dct_manifest = xml_dict.get("manifest") - default_remote = dct_manifest.get("default").get("@remote") + if not dct_manifest: + return [] + if dct_manifest.get("default"): + default_remote = dct_manifest.get("default").get("@remote") + else: + default_remote = None lst_remote = dct_manifest.get("remote") if type(lst_remote) is dict: lst_remote = [lst_remote] @@ -306,7 +320,7 @@ class GitTool: "path": path, "relative_path": f"{repo_path}/{path}", "name": name, - "group": group, + "group": groups, } lst_repo.append(data) @@ -349,16 +363,28 @@ class GitTool: """ if filename is None: manifest_file = self.get_manifest_file(repo_path=repo_path) - filename = f"{repo_path}/{manifest_file}" + filename = os.path.normpath(os.path.join(repo_path, manifest_file)) with open(filename) as xml: xml_as_string = xml.read() xml_dict = xmltodict.parse(xml_as_string) dct_manifest = xml_dict.get("manifest") + if not dct_manifest: + return {}, {}, None default_remote = dct_manifest.get("default") lst_remote = dct_manifest.get("remote") + if type(lst_remote) is dict: + lst_remote = [lst_remote] lst_project = dct_manifest.get("project") - dct_remote = {a.get("@name"): a for a in lst_remote} - dct_project = {a.get("@name"): a for a in lst_project} + if type(lst_project) is dict: + lst_project = [lst_project] + if lst_remote: + dct_remote = {a.get("@name"): a for a in lst_remote} + else: + dct_remote = {} + if lst_project: + dct_project = {a.get("@name"): a for a in lst_project} + else: + dct_project = {} return dct_remote, dct_project, default_remote @staticmethod @@ -395,6 +421,8 @@ class GitTool: def generate_generate_config(self, repo_path="./", filter_group=None): filename_locally = f"{repo_path}script/generate_config.sh" + if not filter_group: + filter_group = self.odoo_version_long lst_repo = self.get_repo_info( repo_path=repo_path, filter_group=filter_group ) @@ -403,6 +431,7 @@ class GitTool: # Exception, ignore addons/OCA_web and root if repo.get("path") in ["addons/OCA_web", "odoo", "image_db"]: continue + # groups = repo.get("group") update_repo = repo.get("path") # Use variable instead of hardcoded path if update_repo.startswith("addons.odoo"): @@ -460,7 +489,7 @@ class GitTool: dct_project={}, default_remote=None, keep_original=False, - default_branch=DEFAULT_BRANCH, + default_branch=None, ): """ Generate repo manifest @@ -474,10 +503,6 @@ class GitTool: :param default_branch: default branch name :return: """ - if not output: - raise Exception( - "Cannot generate manifest with missing output filename." - ) lst_remote = [] lst_remote_name = [] lst_project = [] @@ -604,7 +629,7 @@ class GitTool: lst_default, key=lambda key: key.get("@remote") ) lst_order_project = sorted( - lst_project, key=lambda key: key.get("@name") + lst_project, key=lambda key: key.get("@name") + key.get("@path") ) dct_repo = OrderedDict( @@ -647,8 +672,14 @@ class GitTool: str_xml_text = str_xml_text.replace("\t", " ") # create file - with open(output, mode="w") as file: - file.writelines(str_xml_text + "\n") + output_dirname = os.path.dirname(output) + if not os.path.exists(output_dirname): + pathlib.Path(output_dirname).mkdir(parents=True, exist_ok=True) + if output: + with open(output, mode="w") as file: + file.writelines(str_xml_text + "\n") + else: + print(str_xml_text + "\n") def generate_git_modules( self, lst_repo: List[Struct], repo_path: str = "./" @@ -742,6 +773,11 @@ class GitTool: :param repo_path: path to search .repo :return: manifest file used for Repo """ + file = os.path.join( + repo_path, ".repo", "local_manifests", "erplibre_manifest.xml" + ) + if os.path.exists(file): + return file file = f"{repo_path}/.repo/manifest.xml" if not os.path.exists(file): return "" diff --git a/script/git/repo_diff_last_version.sh b/script/git/repo_diff_last_version.sh index 6a13911..f919f67 100755 --- a/script/git/repo_diff_last_version.sh +++ b/script/git/repo_diff_last_version.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash LAST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) -./.venv/repo forall -pc "git diff ERPLibre/${LAST_TAG}..HEAD" +.venv.erplibre/bin/repo forall -pc "git diff ERPLibre/${LAST_TAG}..HEAD" # For actual repo git diff ${LAST_TAG}..HEAD diff --git a/script/git/repo_diff_stat_last_version.sh b/script/git/repo_diff_stat_last_version.sh index 40ebae1..3dbd749 100755 --- a/script/git/repo_diff_stat_last_version.sh +++ b/script/git/repo_diff_stat_last_version.sh @@ -4,7 +4,7 @@ Color_Off='\033[0m' # Text Reset BOLD='\033[1m' # Black LAST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) -./.venv/repo forall -pc "git diff --stat ERPLibre/${LAST_TAG}..HEAD" +.venv.erplibre/bin/repo forall -pc "git diff --stat ERPLibre/${LAST_TAG}..HEAD" echo "" echo -e "${BOLD}project /${Color_Off}" diff --git a/script/ide/pycharm_configuration.py b/script/ide/pycharm_configuration.py index 75a3c60..8d24fcc 100755 --- a/script/ide/pycharm_configuration.py +++ b/script/ide/pycharm_configuration.py @@ -376,7 +376,7 @@ def add_configuration(dct_xml, file_name, config): {"@name": "PARENT_ENVS", "@value": "true"}, { "@name": "SDK_HOME", - "@value": "$PROJECT_DIR$/.venv/bin/python", + "@value": "$PROJECT_DIR$/.venv.erplibre/bin/python", }, { "@name": "WORKING_DIRECTORY", diff --git a/script/install/install_daemon.sh b/script/install/install_daemon.sh index e3fae19..409d368 100755 --- a/script/install/install_daemon.sh +++ b/script/install/install_daemon.sh @@ -49,11 +49,12 @@ sudo systemctl daemon-reload sudo systemctl enable ${EL_CONFIG}.service sudo su ${EL_USER} -c "sudo rm -f /tmp/${EL_USER}run.sh" +# TODO this is outdated cat < /tmp/${EL_USER}run.sh #!/usr/bin/env bash cd ${EL_HOME_ERPLIBRE} -source ./.venv/bin/activate -python3 ${EL_HOME_ERPLIBRE}/odoo/odoo-bin -c ${EL_HOME_ERPLIBRE}/config.conf --limit-time-real 99999 --limit-time-cpu 99999 $@ +source ./.venv.erplibre/bin/activate +python3 ${EL_HOME_ERPLIBRE}/odoo18.0/odoo/odoo-bin -c ${EL_HOME_ERPLIBRE}/config.conf --limit-time-real 99999 --limit-time-cpu 99999 $@ EOF echo -e "* Security Run File" diff --git a/script/install/install_erplibre.sh b/script/install/install_erplibre.sh new file mode 100755 index 0000000..9173baf --- /dev/null +++ b/script/install/install_erplibre.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# TODO deprecated, this is moved into install_locally.sh to be sure venv is installed and force take specified supported version +python3 -m venv .venv.erplibre +source .venv.erplibre/bin/activate +pip3 install -r requirement/erplibre_require-ments.txt diff --git a/script/install/install_git_repo.sh b/script/install/install_git_repo.sh new file mode 100755 index 0000000..54c7214 --- /dev/null +++ b/script/install/install_git_repo.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +VENV_ERPLIBRE_PATH=$(cat "conf/python-erplibre-venv" | xargs) + +VENV_REPO_PATH=${VENV_ERPLIBRE_PATH}/bin/repo +# Install git-repo if missing +if [[ ! -f ${VENV_REPO_PATH} ]]; then + echo "\n---- Install git-repo from Google APIS ----" + curl https://storage.googleapis.com/git-repo-downloads/repo > ${VENV_REPO_PATH} + chmod +x ${VENV_REPO_PATH} + sed -i 1d ${VENV_REPO_PATH} + PYTHON_HASHBANG="#!./${VENV_ERPLIBRE_PATH}/bin/python" + sed -i "1 i ${PYTHON_HASHBANG}" ${VENV_REPO_PATH} +fi diff --git a/script/install/install_locally.sh b/script/install/install_locally.sh index cb90b31..733bb00 100755 --- a/script/install/install_locally.sh +++ b/script/install/install_locally.sh @@ -3,7 +3,7 @@ . ./env_var.sh EL_USER=${USER} EL_HOME=$PWD -EL_HOME_ODOO="${EL_HOME}/odoo" +EL_HOME_ODOO="${EL_HOME}/odoo${EL_ODOO_VERSION}/odoo" #EL_INSTALL_WKHTMLTOPDF="True" #EL_PORT="8069" #EL_LONGPOLLING_PORT="8072" @@ -12,132 +12,68 @@ EL_HOME_ODOO="${EL_HOME}/odoo" #EL_CONFIG="${EL_USER}" #EL_MINIMAL_ADDONS="False" #EL_INSTALL_NGINX="True" +FILE_INSTALLATION_VERSION=".repo/installed_odoo_version.txt" Red='\033[0;31m' # Red Color_Off='\033[0m' # Text Reset ./script/generate_config.sh -#echo -e "\n---- Install Odoo with addons module ----" -#git submodule update --init - # Generate empty addons if missing path_addons_addons="./addons.odoo${EL_ODOO_VERSION}/addons" if [[ ! -d "${path_addons_addons}" ]]; then mkdir -p "${path_addons_addons}" fi -PYENV_PATH=~/.pyenv # example, 3.7.8 will be 3.7 into PYTHON_VERSION_MAJOR -PYTHON_VERSION_MAJOR=$(echo "$EL_PYTHON_VERSION" | sed 's/\.[^\.]*$//') -PYENV_VERSION_PATH=${PYENV_PATH}/versions/${EL_PYTHON_VERSION} -PYTHON_EXEC=${PYENV_VERSION_PATH}/bin/python -VENV_PATH=./.venv -LOCAL_PYTHON_EXEC=${VENV_PATH}/bin/python -VENV_REPO_PATH=${VENV_PATH}/repo -VENV_MULTILINGUAL_MARKDOWN_PATH=${VENV_PATH}/multilang_md.py -#POETRY_PATH=~/.local/bin/poetry -POETRY_PATH=${VENV_PATH}/bin/poetry +PYTHON_VERSION_MAJOR=$(echo "$EL_PYTHON_ODOO_VERSION" | sed 's/\.[^\.]*$//') +VENV_ERPLIBRE_PATH=$(cat "conf/python-erplibre-venv" | xargs) +VENV_ODOO_PATH=".venv.${EL_ERPLIBRE_VERSION}" +POETRY_ODOO_PATH=${VENV_ERPLIBRE_PATH}/bin/poetry export WITH_POETRY_INSTALLATION=1 if [[ ! -n "${DOCKER_BUILD}" ]]; then - echo "Python path version home" - echo ${PYENV_VERSION_PATH} - echo "Python path version local" - echo ${LOCAL_PYTHON_EXEC} - - if [[ ! -d "${PYENV_PATH}" ]]; then - echo -e "\n---- Installing pyenv in ${PYENV_PATH} ----" - # export PYENV_GIT_TAG=v2.3.35 - # To change version - # rm ~/.pyenv to uninstall it - curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash - fi - - echo -e "\n---- Export pyenv in ${PYENV_PATH} ----" - export PATH="${PYENV_PATH}/bin:$PATH" - eval "$(pyenv init -)" - eval "$(pyenv virtualenv-init -)" - - if [[ ! -d "${PYENV_VERSION_PATH}" ]]; then - echo -e "\n---- Installing python ${PYTHON_VERSION} with pyenv in ${PYENV_VERSION_PATH} ----" - yes n|pyenv install ${PYTHON_VERSION} - if [[ $retVal -ne 0 ]]; then - echo -e "${Red}Error${Color_Off} when installing pyenv" - exit 1 - fi - fi - - pyenv local ${PYTHON_VERSION} - - if [[ ! -d ${VENV_PATH} ]]; then - echo -e "\n---- Create Virtual environment Python ----" - if [[ -e ${PYTHON_EXEC} ]]; then - ${PYTHON_EXEC} -m venv .venv - retVal=$? - if [[ $retVal -ne 0 ]]; then - echo "Virtual environment, error when creating .venv" - exit 1 - fi - else - echo "Missing pyenv, please refer installation guide." - exit 1 - fi - fi - source ./.venv/bin/activate + # Install ERPLibre venv + echo -e "Install ${VENV_ERPLIBRE_PATH} with ${EL_PYTHON_ERPLIBRE_VERSION}" + ./script/install/install_venv.sh "ERPLibre" "${VENV_ERPLIBRE_PATH}" "${EL_PYTHON_ERPLIBRE_VERSION}" + # Install Odoo venv + echo -e "Install ${VENV_ODOO_PATH} with ${EL_PYTHON_ODOO_VERSION}" + ./script/install/install_venv.sh "Odoo" "${VENV_ODOO_PATH}" "${EL_PYTHON_ODOO_VERSION}" else mkdir .venv fi -#if [[ ! -d "${POETRY_PATH}" ]]; then -# # Delete directory ~/.poetry and .venv to force update to new version -# echo -e "\n---- Installing poetry ${LOCAL_PYTHON_EXEC} for reliable python package ----" -# # TODO self update poetry with `poetry self update ${POETRY_VERSION}` -# curl -sSL https://install.python-poetry.org | POETRY_VERSION=${EL_POETRY_VERSION} ${LOCAL_PYTHON_EXEC} - -y -#fi +source ./${VENV_ERPLIBRE_PATH}/bin/activate +echo -e "Upgrade pip to ${VENV_ERPLIBRE_PATH}" +pip install --upgrade pip +pip install -r requirement/erplibre_require-ments.txt -# Install git-repo if missing -if [[ ! -f ${VENV_REPO_PATH} ]]; then - echo "\n---- Install git-repo from Google APIS ----" - curl https://storage.googleapis.com/git-repo-downloads/repo > ${VENV_REPO_PATH} - chmod +x ${VENV_REPO_PATH} - sed -i 1d ${VENV_REPO_PATH} - PYTHON_HASHBANG="#!./.venv/bin/python" - sed -i "1 i ${PYTHON_HASHBANG}" ${VENV_REPO_PATH} -fi +./script/install/install_git_repo.sh + +source ${VENV_ODOO_PATH}/bin/activate +echo -e "Upgrade pip to ${VENV_ODOO_PATH}" +pip install --upgrade pip -# Make .venv active -if [[ "${OSTYPE}" == "darwin"* ]]; then - echo -e "=======>source .venv/bin/activate here!!! <===============" - source .venv/bin/activate -fi echo -e "\n---- Installing poetry dependency ----" -${VENV_PATH}/bin/pip install --upgrade pip -# Force python instead of changing env -#/home/"${USER}"/.poetry/bin/poetry env use ${LOCAL_PYTHON_EXEC} -# source $HOME/.poetry/env -#${LOCAL_PYTHON_EXEC} ~/.poetry/bin/poetry env use ${VENV_PATH}/bin/python3 -#${LOCAL_PYTHON_EXEC} ~/.poetry/bin/poetry install -#${POETRY_PATH} install if [[ -z "${EL_POETRY_VERSION}" ]]; then echo -e "${Red}Error${Color_Off} missing poetry version, please check file .poetry-version" cat .poetry-version + ls -la exit 1 fi # Delete artifacts created by pip, cause error in next "poetry install" -if [[ ! -f "${POETRY_PATH}" ]]; then - ${VENV_PATH}/bin/pip install poetry==${EL_POETRY_VERSION} - ${VENV_PATH}/bin/poetry --version +if [[ ! -f "${POETRY_ODOO_PATH}" ]]; then + echo -e "Install Poetry ${POETRY_ODOO_PATH}" + pip install poetry==${EL_POETRY_VERSION} + poetry --version # Fix broken poetry by installing ignored dependence - # ${VENV_PATH}/bin/pip install vatnumber - # ${VENV_PATH}/bin/pip install suds-jurko - # ${VENV_PATH}/bin/poetry lock --no-update + # poetry lock --no-update # To fix keyring problem when installation is blocked, use export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring if [[ ${WITH_POETRY_INSTALLATION} -ne 0 ]]; then - ${VENV_PATH}/bin/poetry install --no-root -vvv + poetry install --no-root -vvv fi retVal=$? if [[ $retVal -ne 0 ]]; then @@ -149,6 +85,18 @@ fi # Delete artifacts created by pip, cause error in next "poetry install" rm -rf artifacts -# Link for dev +# Link for dev tools into Odoo echo -e "\n---- Add link dependency in site-packages of Python ----" -ln -fs "${EL_HOME_ODOO}/odoo" "${EL_HOME}/.venv/lib/python${PYTHON_VERSION_MAJOR}/site-packages/" +# TODO this link can break, the symbolic link is maybe not created +ln -fs "${EL_HOME_ODOO}/odoo" "${EL_HOME}/${VENV_ODOO_PATH}/lib/python${PYTHON_VERSION_MAJOR}/site-packages/" + +# Force to return to erplibre source +source ./${VENV_ERPLIBRE_PATH}/bin/activate + +# Add trace of installation +LINE_TO_ADD="odoo${EL_ODOO_VERSION}" +mkdir -p "$(dirname "$FILE_INSTALLATION_VERSION")" +touch "$FILE_INSTALLATION_VERSION" +if ! grep -qxF "$LINE_TO_ADD" "$FILE_INSTALLATION_VERSION"; then + echo "$LINE_TO_ADD" >> "$FILE_INSTALLATION_VERSION" +fi diff --git a/script/install/install_locally_dev.sh b/script/install/install_locally_dev.sh index def7ad4..e0e9e8d 100755 --- a/script/install/install_locally_dev.sh +++ b/script/install/install_locally_dev.sh @@ -32,7 +32,7 @@ npm install #cd script/OCA_maintainer-tools || exit ## virtualenv is not installed by default ##virtualenv env -#../../.venv/bin/python -m venv env +#../../.venv.erplibre/bin/python -m venv env #. env/bin/activate #pip install setuptools-rust ## Delete all tag before installing, or break installation, will generate a new one after diff --git a/script/install/install_venv.sh b/script/install/install_venv.sh new file mode 100755 index 0000000..3019feb --- /dev/null +++ b/script/install/install_venv.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +# Check if all 3 parameters are present +if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then + echo "Error: One or more parameters are missing." + echo "Usage: $0 " + exit 1 +fi + +# Assign arguments to variables +CONTEXT="$1" +VENV_PATH="$2" +PYTHON_VERSION="$3" + +# Display variables (for verification) +echo "Context: $CONTEXT" +echo "Venv Path: $VENV_PATH" +echo "Python Version: $PYTHON_VERSION" + +PYENV_PATH=~/.pyenv +PYENV_VERSION_PATH=${PYENV_PATH}/versions/${PYTHON_VERSION} +PYTHON_EXEC=${PYENV_VERSION_PATH}/bin/python +echo "Python path version home" +echo ${PYENV_VERSION_PATH} +#echo "Python path version local" +#echo ${LOCAL_PYTHON_EXEC} + +if [[ ! -d "${PYENV_PATH}" ]]; then + echo -e "\n---- Installing pyenv in ${PYENV_PATH} ----" + # export PYENV_GIT_TAG=v2.3.35 + # To change version + # rm ~/.pyenv to uninstall it + curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash +fi + +echo -e "\n---- Export pyenv in ${PYENV_PATH} ----" +export PATH="${PYENV_PATH}/bin:$PATH" +eval "$(pyenv init -)" +eval "$(pyenv virtualenv-init -)" + +if [[ ! -d "${PYENV_VERSION_PATH}" ]]; then + echo -e "\n---- Installing python ${PYTHON_VERSION} with pyenv in ${PYENV_VERSION_PATH} ----" + # Update all python version list + cd "${PYENV_PATH}" && git pull && cd - + yes n|pyenv install ${PYTHON_VERSION} + if [[ $retVal -ne 0 ]]; then + echo -e "${Red}Error${Color_Off} when installing pyenv" + exit 1 + fi +fi + +# This will write .python-version +# pyenv local ${PYTHON_VERSION} + +if [[ ! -d ${VENV_PATH} ]]; then + echo -e "\n---- Create Virtual environment Python ----" + if [[ -e ${PYTHON_EXEC} ]]; then + ${PYTHON_EXEC} -m venv "${VENV_PATH}" + retVal=$? + if [[ $retVal -ne 0 ]]; then + echo "Virtual environment, error when creating ${VENV_PATH}" + exit 1 + fi + else + echo "Missing pyenv, please refer installation guide. Check variable '${PYTHON_EXEC}'." + exit 1 + fi +fi \ No newline at end of file diff --git a/script/maintenance/autopep8.sh b/script/maintenance/autopep8.sh index 3245c30..9f3d670 100755 --- a/script/maintenance/autopep8.sh +++ b/script/maintenance/autopep8.sh @@ -5,7 +5,7 @@ Color_Off='\033[0m' # Text Reset # This will format all python file # argument 1: directory or file to format NPROC=$(nproc) -source ./script/OCA_maintainer-tools/env/bin/activate +source ./.venv.erplibre/bin/activate oca-autopep8 -j ${NPROC} --max-line-length 79 -ari $@ retVal=$? if [[ $retVal -ne 0 ]]; then diff --git a/script/maintenance/black.sh b/script/maintenance/black.sh index 1ed2812..2205edd 100755 --- a/script/maintenance/black.sh +++ b/script/maintenance/black.sh @@ -4,7 +4,7 @@ Color_Off='\033[0m' # Text Reset # This will format all python file # argument 1: directory or file to format -source ./.venv/bin/activate +source ./.venv.erplibre/bin/activate black -l 79 --preview -t py37 "$@" retVal=$? if [[ $retVal -ne 0 ]]; then diff --git a/script/maintenance/format_python.sh b/script/maintenance/format_python.sh index f17ec1e..d685032 100755 --- a/script/maintenance/format_python.sh +++ b/script/maintenance/format_python.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source ./.venv/bin/activate +source ./.venv.erplibre/bin/activate isort --profile black -l 79 "$@" -#./.venv/bin/isort --profile black -l 79 "$@" +#./.venv.erplibre/bin/isort --profile black -l 79 "$@" ./script/maintenance/black.sh "$@" diff --git a/script/manifest/update_manifest_dev.sh b/script/manifest/update_manifest_dev.sh index 91623bc..3558c24 100755 --- a/script/manifest/update_manifest_dev.sh +++ b/script/manifest/update_manifest_dev.sh @@ -6,5 +6,5 @@ #EL_MANIFEST_DEV="./manifest/default.dev.xml" # Update git-repo -./.venv/repo init -u https://github.com/ERPLibre/ERPLibre -b $(git rev-parse --verify HEAD) -m ${EL_MANIFEST_DEV} -./.venv/repo sync -v +.venv.erplibre/bin/repo init -u https://github.com/ERPLibre/ERPLibre -b $(git rev-parse --verify HEAD) -m ${EL_MANIFEST_DEV} +.venv.erplibre/bin/repo sync -v diff --git a/script/manifest/update_manifest_local_dev.sh b/script/manifest/update_manifest_local_dev.sh index 418e29a..fdeccde 100755 --- a/script/manifest/update_manifest_local_dev.sh +++ b/script/manifest/update_manifest_local_dev.sh @@ -14,7 +14,10 @@ else MANIFEST_TARGET="$EL_MANIFEST_DEV" fi -./.venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --verify HEAD) -m ${MANIFEST_TARGET} "$@" -./.venv/repo sync -v -m ${MANIFEST_TARGET} +# Generate local manifest +.venv.erplibre/bin/python ./script/git/git_merge_repo_manifest.py --output .repo/local_manifests/erplibre_manifest.xml --with_OCA + +.venv.erplibre/bin/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --verify HEAD) -m ${MANIFEST_TARGET} "$@" +.venv.erplibre/bin/repo sync -c -j $(nproc --all) -v -m ${MANIFEST_TARGET} kill ${DAEMON_PID} diff --git a/script/manifest/update_manifest_local_dev_code_generator.sh b/script/manifest/update_manifest_local_dev_code_generator.sh index 251067a..0aa689e 100755 --- a/script/manifest/update_manifest_local_dev_code_generator.sh +++ b/script/manifest/update_manifest_local_dev_code_generator.sh @@ -15,7 +15,7 @@ else MANIFEST_TARGET="$EL_MANIFEST_DEV" fi -./.venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --verify HEAD) -m ${MANIFEST_TARGET} -g base,code_generator -./.venv/repo sync -v -m ${MANIFEST_TARGET} +.venv.erplibre/bin/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --verify HEAD) -m ${MANIFEST_TARGET} -g base,code_generator +.venv.erplibre/bin/repo sync -c -j $(nproc --all) -v -m ${MANIFEST_TARGET} kill ${DAEMON_PID} diff --git a/script/manifest/update_manifest_local_prod.sh b/script/manifest/update_manifest_local_prod.sh index b3df781..c5a962a 100755 --- a/script/manifest/update_manifest_local_prod.sh +++ b/script/manifest/update_manifest_local_prod.sh @@ -15,7 +15,7 @@ else MANIFEST_TARGET="$EL_MANIFEST_DEV" fi -./.venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --verify HEAD) -m ${MANIFEST_TARGET} -./.venv/repo sync -v -m ${MANIFEST_TARGET} +.venv.erplibre/bin/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --verify HEAD) -m ${MANIFEST_TARGET} +.venv.erplibre/bin/repo sync -c -j $(nproc --all) -v -m ${MANIFEST_TARGET} kill ${DAEMON_PID} diff --git a/script/manifest/update_manifest_prod.sh b/script/manifest/update_manifest_prod.sh index 1e1eaaa..c2f8755 100755 --- a/script/manifest/update_manifest_prod.sh +++ b/script/manifest/update_manifest_prod.sh @@ -6,5 +6,5 @@ #EL_MANIFEST_DEV="./manifest/default.dev.xml" # Update git-repo -./.venv/repo init -u https://github.com/ERPLibre/ERPLibre -b $(git rev-parse --verify HEAD) -./.venv/repo sync -v +.venv.erplibre/bin/repo init -u https://github.com/ERPLibre/ERPLibre -b $(git rev-parse --verify HEAD) +.venv.erplibre/bin/repo sync -v -j $(nproc --all) diff --git a/script/poetry/poetry_add_build_dependency.sh b/script/poetry/poetry_add_build_dependency.sh index 6699e2b..6c1cfa2 100755 --- a/script/poetry/poetry_add_build_dependency.sh +++ b/script/poetry/poetry_add_build_dependency.sh @@ -2,7 +2,7 @@ Red='\033[0;31m' # Red Color_Off='\033[0m' # Text Reset -./.venv/bin/poetry add -vv $(grep -v ";" ./.venv/build_dependency.txt | grep -v "*" ) +./.venv.$(cat ".erplibre-version" | xargs)/bin/poetry add -vv $(grep -v ";" ./.venv.$(cat ".erplibre-version" | xargs)/build_dependency.txt | grep -v "*" ) # poetry add -vv $(grep -v ";" ./.venv/build_dependency.txt | grep -v "*" | sed 's/==/@^/' ) # poetry export -f ./.venv/build_dependency.txt --dev | poetry run -- pip install -r /dev/stdin retVal=$? diff --git a/script/selenium/install.md b/script/selenium/install.md index c44407f..ef6d25c 100644 --- a/script/selenium/install.md +++ b/script/selenium/install.md @@ -1,6 +1,6 @@ wget https://github.com/mozilla/geckodriver/releases/download/v0.34.0/geckodriver-v0.34.0-linux64.tar.gz tar xvf geckodriver-v0.34.0-linux64.tar.gz -sudo mv ./.venv/geckodriver /usr/bin/geckdriver +sudo mv ./.venv.erplibre/geckodriver /usr/bin/geckdriver pip install selenium diff --git a/script/statistic/code_count.sh b/script/statistic/code_count.sh index 4eeb285..992f436 100755 --- a/script/statistic/code_count.sh +++ b/script/statistic/code_count.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash # all argument is directory/file separate by space -./.venv/bin/pygount --duplicates --folders-to-skip="[...],*/libs/*,*/lib/*,lib" --names-to-skip="[...],*.min.*" --suffix=py,xml,html,js,csv,css,scss --format=summary "$@" +./.venv.erplibre/bin/pygount --duplicates --folders-to-skip="[...],*/libs/*,*/lib/*,lib" --names-to-skip="[...],*.min.*" --suffix=py,xml,html,js,csv,css,scss --format=summary "$@" diff --git a/script/test/run_parallel_test.py b/script/test/run_parallel_test.py index bb17616..474a1c2 100755 --- a/script/test/run_parallel_test.py +++ b/script/test/run_parallel_test.py @@ -38,7 +38,7 @@ if not os.path.isfile(FILENAME_ODOO_VERSION): with open(".odoo-version", "r") as f: ODOO_VERSION = f.readline() -LOG_FILE = "./.venv/make_test.log" +LOG_FILE = "./.venv.erplibre/make_test.log" CONFIG_TESTCASE_JSON = f"./script/test/config_testcase.odoo{ODOO_VERSION}.json" diff --git a/script/todo/todo.json b/script/todo/todo.json index 282ab3f..7f74333 100644 --- a/script/todo/todo.json +++ b/script/todo/todo.json @@ -18,7 +18,7 @@ "function": [ { "prompt_description": "Ouvrir ERPLibre avec TODO \uD83E\uDD16", - "command": "./.venv/bin/python ./script/selenium/web_login.py" + "command": "./.venv.erplibre/bin/python ./script/selenium/web_login.py" } ], "update_from_makefile": [ diff --git a/script/version/change_python_version.sh b/script/version/change_python_version.sh index e33fff8..86cbb5e 100755 --- a/script/version/change_python_version.sh +++ b/script/version/change_python_version.sh @@ -6,7 +6,7 @@ input=".python-version" while IFS= read -r line do echo -e "Actual version $line" - sed -i -e "s/$line/$1/g" ./.python-version + sed -i -e "s/$line/$1/g" ./.python-odoo-version sed -i -e "s/$line/$1/g" ./docker/Dockerfile.base sed -i -e "s/$line/$1/g" ./script/install/install_OSX_dependency.sh sed -i -e "s/$line/$1/g" ./pyproject.toml diff --git a/script/version/update_env_version.py b/script/version/update_env_version.py index 5d5a4e9..132a901 100755 --- a/script/version/update_env_version.py +++ b/script/version/update_env_version.py @@ -2,7 +2,7 @@ # © 2021-2024 TechnoLibre (http://www.technolibre.ca) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -# This script need only basic importation +# This script need only basic importation, it needs to be supported by python of your system import argparse import json import logging @@ -18,11 +18,11 @@ _logger = logging.getLogger(__name__) PROJECT_NAME = os.path.basename(os.getcwd()) VERSION_DATA_FILE = os.path.join("conf", "supported_version_erplibre.json") -VERSION_PYTHON_FILE = os.path.join(".python-version") +VERSION_PYTHON_FILE = os.path.join(".python-odoo-version") +INSTALLED_ODOO_VERSION_FILE = ".repo/installed_odoo_version.txt" VERSION_ERPLIBRE_FILE = os.path.join(".erplibre-version") VERSION_ODOO_FILE = os.path.join(".odoo-version") VERSION_POETRY_FILE = os.path.join(".poetry-version") -VENV_FILE = os.path.join(".venv") ADDONS_PATH = os.path.join("addons") ODOO_PATH = os.path.join(".", "odoo") VENV_TEMPLATE_FILE = ".venv.%s" @@ -110,7 +110,7 @@ def get_config(): parser.add_argument( "--force_install", action="store_true", - help="Will erase .venv and create symbolic link after installation.", + help="Will erase .venv.odooVersion and create symbolic link after installation.", ) parser.add_argument( "--force_repo", @@ -157,7 +157,6 @@ class Update: self.expected_pyproject_path = None self.expected_poetry_lock_name = None self.expected_poetry_lock_path = None - self.do_backup_venv = False def check_version_data(self): die( @@ -184,10 +183,13 @@ class Update: self.python_version = txt.read().strip() with open(VERSION_ODOO_FILE) as txt: self.odoo_version = txt.read().strip() + with open(VERSION_POETRY_FILE) as txt: + poetry_version = txt.read().strip() # Show actual version _logger.info(f"Python version: {self.python_version}") _logger.info(f"Odoo version: {self.odoo_version}") + _logger.info(f"Poetry version: {poetry_version}") erplibre_version_to_search = ERPLIBRE_TEMPLATE_VERSION % ( self.odoo_version, self.python_version, @@ -212,6 +214,13 @@ class Update: ) return False + if os.path.exists(INSTALLED_ODOO_VERSION_FILE): + with open(INSTALLED_ODOO_VERSION_FILE) as txt: + lst_version_installed = sorted(txt.read().splitlines()) + str_installed_version = "Installed version: " + ", ".join( + lst_version_installed + ) + _logger.info(str_installed_version) return True def validate_version(self): @@ -323,7 +332,9 @@ class Update: ADDONS_TEMPLATE_FILE % self.new_version_odoo ) self.expected_odoo_name = ODOO_TEMPLATE_FILE % self.new_version_odoo - self.expected_odoo_path = os.path.join(".", self.expected_odoo_name, "odoo", ".") + self.expected_odoo_path = os.path.join( + ".", self.expected_odoo_name, "odoo", "." + ) self.expected_pip_requirement_path = os.path.join( ".", "requirement", self.expected_pip_requirement_name ) @@ -339,16 +350,7 @@ class Update: def validate_environment(self): status = True - # Validate .venv - status &= self.update_link_file( - "Virtual environnement", - VENV_FILE, - self.expected_venv_name, - is_directory=True, - do_delete_source=self.config.install_dev - or self.config.force_install, - ) - venv_exist = os.path.exists(VENV_FILE) + venv_exist = os.path.exists(self.expected_venv_name) if not venv_exist and not self.config.install_dev: _logger.info("Relaunch this script with --install_dev argument.") # Validate Odoo repo @@ -405,24 +407,21 @@ class Update: def update_environment(self): status = True - do_action = bool(any([self.config.install_dev, self.config.install])) - if self.do_backup_venv and do_action: - venv_backup_name = ( - f".venv_backup_{time.strftime('%Yy%mm%dd-%Hh%Mm%Ss')}" - ) - shutil.move(VENV_FILE, venv_backup_name) - self.execute_log.append(f"Move .venv to backup {venv_backup_name}") if self.config.force_repo: # TODO add script to check difference before erase all os.system("./script/git/clean_repo_manifest.sh") self.execute_log.append( f"Clear all repo from manifest, everything is deleted" ) - if self.config.force_install: - os.system(f"rm -rf ./{VENV_FILE}") - self.execute_log.append(f"Remove ./{VENV_FILE}") # Always overwrite version + _logger.info( + f"Update local file, " + f"python version '{self.new_version_python}', " + f"erplibre version '{self.new_version_erplibre}', " + f"odoo version '{self.new_version_odoo}', " + f"poetry version '{self.new_version_poetry}'" + ) with open(VERSION_PYTHON_FILE, "w") as txt: txt.write(self.new_version_python) with open(VERSION_ERPLIBRE_FILE, "w") as txt: @@ -433,28 +432,21 @@ class Update: txt.write(self.new_version_poetry) if self.config.is_in_installation or self.config.is_in_switch: - addons_path_with_version = ( - ADDONS_TEMPLATE_FILE % self.new_version_odoo - ) - # To support multiple addons directory, change name before run git repo - for addons_path in os.listdir("."): - if ( - addons_path.startswith("addons") - and addons_path != addons_path_with_version - ): - os.rename(addons_path, addons_path + "TEMP") + # addons_path_with_version = ( + # ADDONS_TEMPLATE_FILE % self.new_version_odoo + # ) + # # To support multiple addons directory, change name before run git repo + # for addons_path in os.listdir("."): + # if ( + # addons_path.startswith("addons") + # and addons_path != addons_path_with_version + # ): + # os.rename(addons_path, addons_path + "TEMP") # TODO need to be force if installation path is all good, return True if self.config.install_dev: _logger.info("Installation.") status = self.install_erplibre() - - # Re-update if launch installation - if self.config.install_dev: - self._update_directory_to_link( - VENV_FILE, self.expected_venv_name - ) - # self._update_directory_to_link(ADDONS_PATH, self.expected_addons_name) elif self.config.is_in_switch: _logger.info("Switch") self.execute_log.append(f"System update") @@ -463,13 +455,13 @@ class Update: ) # To support multiple addons directory, remove TEMP - for addons_path in os.listdir("."): - if ( - addons_path.startswith("addons") - and addons_path != addons_path_with_version - and addons_path.endswith("TEMP") - ): - os.rename(addons_path, addons_path[:-4]) + # for addons_path in os.listdir("."): + # if ( + # addons_path.startswith("addons") + # and addons_path != addons_path_with_version + # and addons_path.endswith("TEMP") + # ): + # os.rename(addons_path, addons_path[:-4]) for addons_path in os.listdir("."): if addons_path.startswith("addons"): # In same time, force to create addons if not existing @@ -478,29 +470,19 @@ class Update: os.makedirs(addons_dir_path) # Force create addons link - if os.path.isdir(ADDONS_PATH): - if os.path.islink(ADDONS_PATH): - os.remove(ADDONS_PATH) - else: - os.rename( - ADDONS_PATH, - ADDONS_PATH - + "_" - + time.strftime("%Yy%mm%dd-%Hh%Mm%Ss"), - ) - os.symlink(addons_path_with_version, ADDONS_PATH) + # if os.path.isdir(ADDONS_PATH): + # if os.path.islink(ADDONS_PATH): + # os.remove(ADDONS_PATH) + # else: + # os.rename( + # ADDONS_PATH, + # ADDONS_PATH + # + "_" + # + time.strftime("%Yy%mm%dd-%Hh%Mm%Ss"), + # ) + # os.symlink(addons_path_with_version, ADDONS_PATH) return status - def _update_directory_to_link(self, dir_to_check, link_name): - actuel_venv_is_symlink = os.path.islink(dir_to_check) - if not actuel_venv_is_symlink: - # Move it and create a symlink - shutil.move(dir_to_check, link_name) - os.symlink(link_name, dir_to_check) - msg = f"Create symbolic link {link_name} to {dir_to_check}" - _logger.info(msg) - self.execute_log.append(msg) - def print_log(self): if not self.execute_log: _logger.info("Nothing to do") @@ -514,7 +496,7 @@ class Update: if not pycharm_is_installed or not self.execute_log: return os.system( - "./.venv/bin/python ./script/ide/pycharm_configuration.py --init" + "./.venv.erplibre/bin/python ./script/ide/pycharm_configuration.py --init" ) def install_erplibre(self): @@ -554,7 +536,7 @@ class Update: source_file_is_symlink = os.path.islink(source_file) target_file_exist = os.path.exists(target_file) if not target_file_exist: - _logger.warning(f"'{target_file}' not exist.") + _logger.error(f"'{target_file}' not exist.") do_symlink = False # Case 4 if source_file_is_symlink and not source_file_exist: @@ -581,8 +563,8 @@ class Update: ) os.system(f"ls -lha {source_file}") sys.exit(1) - else: - do_switch_origin_sim = True + # else: + # do_switch_origin_sim = True else: source_file_is_file = os.path.isfile(source_file) if not source_file_is_file: @@ -592,18 +574,18 @@ class Update: ) os.system(f"ls -lha {source_file}") sys.exit(1) - else: - do_switch_origin_sim = True - if do_switch_origin_sim: - # Check if not erase an existing - if target_file_exist: - # Create a backup - new_target_file = f"{target_file}.backup_{time.strftime('%Yy%mm%dd-%Hh%Mm%Ss')}" - else: - new_target_file = target_file + # else: + # do_switch_origin_sim = True + # if do_switch_origin_sim: + # # Check if not erase an existing + # if target_file_exist: + # # Create a backup + # new_target_file = f"{target_file}.backup_{time.strftime('%Yy%mm%dd-%Hh%Mm%Ss')}" + # else: + # new_target_file = target_file # Move it and create a symlink - shutil.move(source_file, new_target_file) - do_symlink = True + # shutil.move(source_file, new_target_file) + # do_symlink = True else: # Case 3 # Is symlink @@ -742,18 +724,20 @@ def main(): update.pycharm_update() # Update OCB configuration - os.system("./.venv/bin/python ./script/git/git_repo_update_group.py") + os.system( + "./.venv.erplibre/bin/python ./script/git/git_repo_update_group.py" + ) os.system("./script/generate_config.sh") # TODO ignore this if installation fail - # TODO this cause an error at first execution, need to source ./.venv/bin/activate and rerun - # subprocess.run(['source', './.venv/bin/activate'], shell=True) + # TODO this cause an error at first execution, need to source ./.venv.erplibre/bin/activate and rerun + # subprocess.run(['source', './.venv.erplibre/bin/activate'], shell=True) # subprocess.run(['make', 'config_gen_all']) # status = os.system(f"make config_gen_all") # # if not status: # print("Please run:") - # print("source ./.venv/bin/activate") + # print("source ./.venv.erplibre/bin/activate") # print("make config_gen_all")