From 8b02efa484d832656c13e0b91af9a25183301697 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Sat, 24 Feb 2024 04:12:34 -0600 Subject: [PATCH] [IMP] Init for Odoo 17.0 --- .copier-answers.yml | 26 +++--- .pre-commit-config.yaml | 60 +++++--------- .pylintrc | 12 +-- .pylintrc-mandatory | 12 +-- .ruff.toml | 30 +++++++ INSTALL.md | 72 ++++++++-------- README.md | 2 +- docker-compose.yml | 17 ++-- helm/README.md | 38 ++++++--- helm/odoo/Chart.yaml | 16 ++-- helm/odoo/requirements.yaml | 32 +++---- odoo/Dockerfile | 2 +- odoo/migration.yml | 13 ++- odoo/requirements.txt | 3 - odoo/setup.py | 2 +- odoo/songs/common.py | 2 +- .../private-addons/customer/__manifest__.py | 3 +- .../elearning_content/__manifest__.py | 4 +- .../data/00-interface/slide.slide.xml | 83 +++++++++++++------ odoo/tests/locust/README.md | 9 +- odoo/tests/locust/tasks/account.py | 2 +- odoo/tests/locust/tasks/crm.py | 3 +- odoo/tests/locust/tasks/project.py | 2 +- odoo/tests/locust/tasks/purchase.py | 3 +- odoo/tests/locust/tasks/sale.py | 3 +- odoo/tests/locust/tasks/stock.py | 3 +- odoo/tests/selenium/README.md | 65 +++++++++------ requirements.txt | 6 +- 28 files changed, 306 insertions(+), 219 deletions(-) create mode 100644 .ruff.toml diff --git a/.copier-answers.yml b/.copier-answers.yml index 9c56dde..680df06 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,22 +1,26 @@ # Do NOT update manually; changes here will be overwritten by Copier -_commit: v1.11.0 +_commit: v1.20 _src_path: gh:oca/oca-addons-repo-template +additional_ruff_rules: [] ci: GitHub -dependency_installation_mode: PIP +convert_readme_fragments_to_markdown: true generate_requirements_txt: true github_check_license: true +github_ci_extra_env: {} github_enable_codecov: true github_enable_makepot: true github_enable_stale_action: true github_enforce_dev_status_compatibility: true include_wkhtmltopdf: false -odoo_version: 16.0 -org_name: Odoo Community Association (OCA) -org_slug: OCA +odoo_test_flavor: Odoo +odoo_version: 17.0 +org_name: Open Source Integrators +org_slug: ursais rebel_module_groups: [] -repo_description: 'TODO: add repo description.' -repo_name: field-service -repo_slug: field-service -repo_website: https://github.com/OCA/field-service -travis_apt_packages: [] -travis_apt_sources: [] +repo_description: Template for an Odoo Project +repo_name: Template for Odoo Project +repo_slug: odoo-template +repo_website: https://github.com/ursais/odoo-template +use_pyproject_toml: true +use_ruff: true + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 287dfc1..d551e44 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,8 @@ exclude: | # Repos using Sphinx to generate docs don't need prettying ^docs/_templates/.*\.html$| # You don't usually want a bot to modify your legal texts - (LICENSE.*|COPYING.*) + (LICENSE.*|COPYING.*)| + helm/odoo/templates default_language_version: python: python3 node: "16.17.0" @@ -28,29 +29,28 @@ repos: language: fail files: "\\.rej$" - repo: https://github.com/oca/maintainer-tools - rev: 4cd2b852214dead80822e93e6749b16f2785b2fe + rev: 451de41fa3e8aa81d077c804322d48632eb5ff74 hooks: # update the NOT INSTALLABLE ADDONS section above - id: oca-update-pre-commit-excluded-addons - id: oca-fix-manifest-website - args: ["https://github.com/OCA/field-service"] - - repo: https://github.com/myint/autoflake - rev: v1.6.1 - hooks: - - id: autoflake + args: ["https://github.com/ursais/odoo-template"] + - id: oca-gen-addon-readme args: - - --expand-star-imports - - --ignore-init-module-imports - - --in-place - - --remove-all-unused-imports - - --remove-duplicate-keys - - --remove-unused-variables - - repo: https://github.com/psf/black - rev: 22.8.0 + - --addons-dir=. + - --branch=17.0 + - --org-name=ursais + - --repo-name=odoo-template + - --if-source-changed + - --keep-source-digest + - --convert-fragments-to-markdown + - repo: https://github.com/OCA/odoo-pre-commit-hooks + rev: v0.0.25 hooks: - - id: black + - id: oca-checks-odoo-module + - id: oca-checks-po - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.7.1 + rev: v4.0.0-alpha.8 hooks: - id: prettier name: prettier (with plugin-xml) @@ -61,7 +61,7 @@ repos: - --plugin=@prettier/plugin-xml files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$ - repo: https://github.com/pre-commit/mirrors-eslint - rev: v8.24.0 + rev: v9.0.0-beta.1 hooks: - id: eslint verbose: true @@ -69,7 +69,7 @@ repos: - --color - --fix - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.5.0 hooks: - id: trailing-whitespace # exclude autogenerated files @@ -91,36 +91,20 @@ repos: - id: mixed-line-ending args: ["--fix=lf"] - repo: https://github.com/asottile/pyupgrade - rev: v2.38.2 + rev: v3.15.1 hooks: - id: pyupgrade args: ["--keep-percent-format"] - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.13.2 hooks: - id: isort name: isort except __init__.py args: - --settings=. exclude: /__init__\.py$ - - repo: https://github.com/acsone/setuptools-odoo - rev: 3.0.3 - hooks: - - id: setuptools-odoo-make-default - - id: setuptools-odoo-get-requirements - args: - - --output - - requirements.txt - - --header - - "# generated from manifests external_dependencies" - - repo: https://gitlab.com/PyCQA/flake8 - rev: 3.9.2 - hooks: - - id: flake8 - name: flake8 - additional_dependencies: ["flake8-bugbear==21.9.2"] - repo: https://github.com/OCA/pylint-odoo - rev: 7.0.2 + rev: v9.0.5 hooks: - id: pylint_odoo name: pylint with optional checks diff --git a/.pylintrc b/.pylintrc index 1ac9420..eafc072 100644 --- a/.pylintrc +++ b/.pylintrc @@ -3,12 +3,12 @@ load-plugins=pylint_odoo score=n [ODOOLINT] -readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst" -manifest_required_authors=Open Source Integrators -manifest_required_keys=license -manifest_deprecated_keys=description,active -license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3 -valid_odoo_versions=16.0 +readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst" +manifest-required-authors=Open Source Integrators +manifest-required-keys=license +manifest-deprecated-keys=description,active +license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3 +valid-odoo-versions=17.0 [MESSAGES CONTROL] disable=all diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory index 43d1292..fa744a2 100644 --- a/.pylintrc-mandatory +++ b/.pylintrc-mandatory @@ -3,12 +3,12 @@ load-plugins=pylint_odoo score=n [ODOOLINT] -readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst" -manifest_required_authors=Open Source Integrators -manifest_required_keys=license -manifest_deprecated_keys=description,active -license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3 -valid_odoo_versions=16.0 +readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst" +manifest-required-authors=Open Source Integrators +manifest-required-keys=license +manifest-deprecated-keys=description,active +license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3 +valid-odoo-versions=17.0 [MESSAGES CONTROL] disable=all diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..0240c75 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,30 @@ + +target-version = "py310" +fix = true + +[lint] +extend-select = [ + "B", + "C90", + "E501", # line too long (default 88) + "I", # isort + "UP", # pyupgrade +] +exclude = ["setup/*"] + +[format] +exclude = ["setup/*"] + +[per-file-ignores] +"__init__.py" = ["F401", "I001"] # ignore unused and unsorted imports in __init__.py +"__manifest__.py" = ["B018"] # useless expression + +[isort] +section-order = ["future", "standard-library", "third-party", "odoo", "odoo-addons", "first-party", "local-folder"] + +[isort.sections] +"odoo" = ["odoo"] +"odoo-addons" = ["odoo.addons"] + +[mccabe] +max-complexity = 16 diff --git a/INSTALL.md b/INSTALL.md index 3b39f2c..4e295d0 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,55 +1,55 @@ # Install Odoo dependencies -* libffi-dev -* libgeoip-dev -* libjpeg-dev -* libldap2-dev -* libsasl2-dev -* libxml2-dev -* libxslt1-dev -* nginx -* node-less -* postfix -* postgresql -* postgresql-server-dev-9.5 -* python-dev -* python-pip -* python-psycopg2 -* python-virtualenv -* zlib1g-dev +- libffi-dev +- libgeoip-dev +- libjpeg-dev +- libldap2-dev +- libsasl2-dev +- libxml2-dev +- libxslt1-dev +- nginx +- node-less +- postfix +- postgresql +- postgresql-server-dev-9.5 +- python-dev +- python-pip +- python-psycopg2 +- python-virtualenv +- zlib1g-dev # Webkit -* Download Webkit from https://github.com/wkhtmltopdf/wkhtmltopdf/releases/tag/0.12.1 -* Install Webkit and create a symlink: +- Download Webkit from https://github.com/wkhtmltopdf/wkhtmltopdf/releases/tag/0.12.1 +- Install Webkit and create a symlink: `# ln -s /usr/local/bin/wkhtmltopdf /usr/bin/wkhtmltopdf` # PostgreSQL -* Create a PostgreSQL user for odoo +- Create a PostgreSQL user for odoo # Odoo -* Create an Odoo user -* Clone the repository -* Change the ownership of the repo to odoo -* Create the environment +- Create an Odoo user +- Clone the repository +- Change the ownership of the repo to odoo +- Create the environment `$ virtualenv env && . env/bin/activate && pip install -r requirements.txt` -* Create /etc/odoo -* Create Odoo config file -* Create Odoo init script -* Create /var/log/odoo -* Create /var/backups/odoo -* Enable and start Odoo +- Create /etc/odoo +- Create Odoo config file +- Create Odoo init script +- Create /var/log/odoo +- Create /var/backups/odoo +- Enable and start Odoo # Nginx -* Create Nginx config file -* Create the SSL directory /etc/nginx/ssl -* Generate the SSL certificate +- Create Nginx config file +- Create the SSL directory /etc/nginx/ssl +- Generate the SSL certificate ``` # openssl req -x509 -nodes -days 365 -newkey rsa:2048 \ @@ -58,6 +58,6 @@ -out /etc/nginx/ssl/odoo.crt ``` -* Change the permission of the certificate file -* Enable new odoo virtual host -* Enable and start Nginx +- Change the permission of the certificate file +- Enable new odoo virtual host +- Enable and start Nginx diff --git a/README.md b/README.md index c7d4868..4b006c1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Odoo 16.0 Template Project +# Template for an Odoo 17 Project ## Table of Contents * [Prerequisites](#Prerequisites) diff --git a/docker-compose.yml b/docker-compose.yml index 552d4aa..f87ec30 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '2' +version: "2" services: db: image: ursa/postgresql:latest @@ -9,16 +9,16 @@ services: - POSTGRES_PASSWORD=odoo - PGDATA=/var/lib/postgresql/data/pgdata volumes: - - 'postgres-data:/var/lib/postgresql/data' + - "postgres-data:/var/lib/postgresql/data" - odoo: + app: build: context: odoo ports: - - '8069:8069' - - '8072:8072' + - "8069:8069" + - "8072:8072" volumes: - - 'odoo-data:/odoo/data' + - "odoo-data:/odoo/data" depends_on: - db environment: @@ -35,10 +35,11 @@ services: - ODOO_ADMIN_USER_PASSWORD=admin - ODOO_DBFILTER=False - ODOO_LIST_DB=True + - ODOO_SERVER_WIDE_MODULES=web stdin_open: true tty: true -# cap_add: -# - sys_ptrace + # cap_add: + # - sys_ptrace mail: image: mailhog/mailhog diff --git a/helm/README.md b/helm/README.md index a9bd6e5..426a025 100644 --- a/helm/README.md +++ b/helm/README.md @@ -1,23 +1,27 @@ # Odoo Deployment ## Table of Contents -* [Development environment](#Development-environment) -* [Test environment](#Test-environment) -* [QA environment](#QA-environment) -* [Production environment](#Production-environment) -* [Secrets](#Secrets) -* [Release](#Release) -* [Known issues](#Known-issues) + +- [Development environment](#Development-environment) +- [Test environment](#Test-environment) +- [QA environment](#QA-environment) +- [Production environment](#Production-environment) +- [Secrets](#Secrets) +- [Release](#Release) +- [Known issues](#Known-issues) ## Development environment Create the project: + ```shell script kubectl create namespace odoo-dev ``` + Edit the variables in helm/odoo/values.yaml Run + ```shell script helm dependency update helm/odoo helm upgrade --install odoo helm/odoo @@ -26,12 +30,15 @@ helm upgrade --install odoo helm/odoo ## Test environment Create the project: + ```shell script kubectl create namespace odoo-test ``` + Edit the variables in helm/odoo/values.test.yaml Run + ```shell script helm upgrade --install odoo -f helm/odoo/values.test.yaml helm/odoo ``` @@ -39,12 +46,15 @@ helm upgrade --install odoo -f helm/odoo/values.test.yaml helm/odoo ## QA environment Create the project: + ```shell script kubectl create namespace odoo-qa ``` + Edit the variables in helm/odoo/values.qa.yaml Run + ```shell script helm upgrade --install odoo -f helm/odoo/values.qa.yaml helm/odoo ``` @@ -52,12 +62,15 @@ helm upgrade --install odoo -f helm/odoo/values.qa.yaml helm/odoo ## Production environment Create the project: + ```shell script kubectl create namespace odoo ``` + Edit the variables in helm/odoo/values.production.yaml Run + ```shell script helm upgrade --install odoo -f helm/odoo/values.production.yaml helm/odoo ``` @@ -89,10 +102,10 @@ kubectl edit secret odoo ## Release -Create a new release in the repository: -https://github.com/ursais/odoo-template/releases +Create a new release in the repository: https://github.com/ursais/odoo-template/releases Update the deployment: + ```shell script TAG=20210527 NAMESPACE=odoo-test @@ -104,6 +117,7 @@ kubectl set image deploy odoo \ ## Backup Install Velero: + ```shell export BUCKET=velerobackup- export REGION=us-east-2 @@ -118,6 +132,7 @@ velero install \ ``` Create schedules: + ```shell velero create schedule full-daily --schedule="@every 24h" velero create schedule odoo-daily --schedule="@every 24h" --include-namespaces -odoo @@ -128,6 +143,5 @@ velero create schedule odoo-dev-daily --schedule="@every 24h" --include-namespac ## Known issues -* https://github.com/bitnami/charts/issues/6121 - Upgrading the PostgreSQL helm chart regenerates the password in the secret and causes - Odoo's connections to fail. +- https://github.com/bitnami/charts/issues/6121 Upgrading the PostgreSQL helm chart + regenerates the password in the secret and causes Odoo's connections to fail. diff --git a/helm/odoo/Chart.yaml b/helm/odoo/Chart.yaml index eff7d74..1856629 100644 --- a/helm/odoo/Chart.yaml +++ b/helm/odoo/Chart.yaml @@ -6,14 +6,14 @@ description: Odoo instance home: https://www.opensourceintegrators.com icon: https://github.com/ursais.png keywords: -- odoo -- crm -- www -- http -- web + - odoo + - crm + - www + - http + - web sources: -- https://github.com/ursais/odoo-template + - https://github.com/ursais/odoo-template maintainers: -- name: Open Source Integrators - email: support@opensourceintegrators.com + - name: Open Source Integrators + email: support@opensourceintegrators.com engine: gotpl diff --git a/helm/odoo/requirements.yaml b/helm/odoo/requirements.yaml index 2e46068..0070e07 100644 --- a/helm/odoo/requirements.yaml +++ b/helm/odoo/requirements.yaml @@ -1,17 +1,17 @@ dependencies: -- name: mailhog - condition: mailhog.enabled - version: 3.x.x - repository: https://codecentric.github.io/helm-charts -- name: postfix - condition: postfix.enabled - version: 0.x.x - repository: https://rasooll.github.io/helm-charts -- name: postgresql - condition: postgresql.enabled - version: 8.x.x - repository: https://charts.bitnami.com/bitnami -- name: redis - condition: redis.enabled - version: 12.x.x - repository: https://charts.bitnami.com/bitnami + - name: mailhog + condition: mailhog.enabled + version: 3.x.x + repository: https://codecentric.github.io/helm-charts + - name: postfix + condition: postfix.enabled + version: 0.x.x + repository: https://rasooll.github.io/helm-charts + - name: postgresql + condition: postgresql.enabled + version: 8.x.x + repository: https://charts.bitnami.com/bitnami + - name: redis + condition: redis.enabled + version: 12.x.x + repository: https://charts.bitnami.com/bitnami diff --git a/odoo/Dockerfile b/odoo/Dockerfile index 15ac56c..a187757 100644 --- a/odoo/Dockerfile +++ b/odoo/Dockerfile @@ -1,4 +1,4 @@ -FROM ursa/odoo-16.0:latest +FROM ursa/odoo-17.0:latest MAINTAINER Open Source Integrators # Copy files diff --git a/odoo/migration.yml b/odoo/migration.yml index b5dbadd..aae9610 100644 --- a/odoo/migration.yml +++ b/odoo/migration.yml @@ -4,8 +4,8 @@ migration: install_args: --log-level=debug backup: command: ' - export DATE=$(date +%Y%m%dT%H%M%S) && - psql -c "CREATE DATABASE $DATE WITH TEMPLATE $PGDATABASE;"' + export DATE=$(date +%Y%m%dT%H%M%S) && psql -c "CREATE DATABASE $DATE WITH + TEMPLATE $PGDATABASE;"' stop_on_failure: true ignore_if: test "${RUNNING_ENV}" != "production" @@ -13,20 +13,19 @@ migration: - version: setup backup: false operations: -# pre: -# - psql -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" + # pre: + # - psql -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" post: - anthem songs.setup.base::main - - /bin/sh -c "VERSION=15.0.1.0.0 anthem songs.environment::main" + - /bin/sh -c "VERSION=17.0.1.0.0 anthem songs.environment::main" addons: upgrade: - customer - - monitoring_status + # - monitoring_status - web_environment_ribbon # modes: # external: # operations: # addons: # upgrade: -# - attachment_??? # - session_redis diff --git a/odoo/requirements.txt b/odoo/requirements.txt index 8a22469..2dc140a 100644 --- a/odoo/requirements.txt +++ b/odoo/requirements.txt @@ -1,5 +1,2 @@ -./odoo -e . # Install the songs - # Add project specific packages below -num2words diff --git a/odoo/setup.py b/odoo/setup.py index 5d1095e..7f6ba3d 100644 --- a/odoo/setup.py +++ b/odoo/setup.py @@ -4,7 +4,7 @@ setup( name="odoo-songs", - version="14.0.1.0.0", + version="17.0.1.0.0", description="Odoo ERP", license="GNU Affero General Public License v3 or later (AGPLv3+)", author="Open Source Integrators", diff --git a/odoo/songs/common.py b/odoo/songs/common.py index 304b2dd..5387e46 100644 --- a/odoo/songs/common.py +++ b/odoo/songs/common.py @@ -25,7 +25,7 @@ def load_csv(ctx, path, delimiter=",", header=None, header_exclude=None): def load_users_csv(ctx, path, delimiter=","): # make sure we don't send any email ctx.env["res.users"].with_context( - {"no_reset_password": True, "tracking_disable": True} + **{"no_reset_password": True, "tracking_disable": True} ) load_csv(ctx, path, delimiter) diff --git a/odoo/src/private-addons/customer/__manifest__.py b/odoo/src/private-addons/customer/__manifest__.py index 563e94f..3939151 100644 --- a/odoo/src/private-addons/customer/__manifest__.py +++ b/odoo/src/private-addons/customer/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Customer", - "version": "15.0.1.0.0", + "version": "17.0.1.0.0", "license": "AGPL-3", "summary": "Customer Configuration and Data", "author": "Open Source Integrators", @@ -11,6 +11,7 @@ "website": "https://www.opensourceintegrators.com", "depends": ["elearning_content"], "data": [], + "sequence": 0, "application": True, "maintainers": ["ursais"], } diff --git a/odoo/src/private-addons/elearning_content/__manifest__.py b/odoo/src/private-addons/elearning_content/__manifest__.py index 372bf0f..dd691e6 100644 --- a/odoo/src/private-addons/elearning_content/__manifest__.py +++ b/odoo/src/private-addons/elearning_content/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Elearning Content", - "version": "15.0.1.0.0", + "version": "17.0.1.0.0", "license": "AGPL-3", "summary": "Training Content and Documentation", "author": "Open Source Integrators", @@ -25,6 +25,6 @@ # Administration # Development ], - "application": True, + "application": False, "maintainers": ["ursais"], } diff --git a/odoo/src/private-addons/elearning_content/data/00-interface/slide.slide.xml b/odoo/src/private-addons/elearning_content/data/00-interface/slide.slide.xml index 7584d3b..7697075 100644 --- a/odoo/src/private-addons/elearning_content/data/00-interface/slide.slide.xml +++ b/odoo/src/private-addons/elearning_content/data/00-interface/slide.slide.xml @@ -5,8 +5,11 @@ Log in 110 webpage - - + + 0
@@ -22,8 +25,11 @@ Browse the menu 120 webpage - - + + 0
@@ -39,8 +45,11 @@ Search, filter and group 130 webpage - - + + 0
@@ -56,8 +65,11 @@ Favorites and Dashboard 140 webpage - - + + 0
@@ -73,8 +85,11 @@ Import/Export 150 webpage - - + + 0
@@ -90,8 +105,11 @@ List 210 webpage - - + + 0
@@ -107,8 +125,11 @@ Form 220 webpage - - + + 0
@@ -124,8 +145,11 @@ Kanban 230 webpage - - + + 0
@@ -141,8 +165,11 @@ Calendar 240 webpage - - + + 0
@@ -158,8 +185,11 @@ Map 250 webpage - - + + 0
@@ -175,8 +205,11 @@ Report an issue 310 webpage - - + + 0
@@ -185,8 +218,10 @@
  • By email to support@opensourceintegrators.com
  • Through the portal at - + https://pm.opensourceintegrators.com/helpdesk/support-1/submit
  • diff --git a/odoo/tests/locust/README.md b/odoo/tests/locust/README.md index 9f7a84b..4e8ebf1 100644 --- a/odoo/tests/locust/README.md +++ b/odoo/tests/locust/README.md @@ -10,15 +10,17 @@ pip install -r requirements.txt ## Running the tests -* Edit `locust.conf` to your needs -* Run +- Edit `locust.conf` to your needs +- Run + ```shell script export ODOO_DB_NAME=Test export ODOO_LOGIN=admin export ODOO_PASSWORD=admin locust --config=locust.conf ``` -* Go to http://localhost:8089 + +- Go to http://localhost:8089 ## Advanced topics @@ -26,6 +28,7 @@ It is possible to set the weight of the users (CRMUser, SaleUser, ProjectUser, PurchaseUser, AccountUser, StockUser) by editing the values in `locustfile.py`. You can also run specific user, for example: + ```shell script locust --config=locust.conf SaleUser ``` diff --git a/odoo/tests/locust/tasks/account.py b/odoo/tests/locust/tasks/account.py index 3598d22..61da095 100644 --- a/odoo/tests/locust/tasks/account.py +++ b/odoo/tests/locust/tasks/account.py @@ -9,7 +9,7 @@ class AccountTaskSet(helper.BaseBackendTaskSet): def on_start(self, *args, **kwargs): - super(AccountTaskSet, self).on_start(*args, **kwargs) + return super().on_start(*args, **kwargs) @task(20) def generate_invoice_from_task(self): diff --git a/odoo/tests/locust/tasks/crm.py b/odoo/tests/locust/tasks/crm.py index cfc722a..5c220ca 100644 --- a/odoo/tests/locust/tasks/crm.py +++ b/odoo/tests/locust/tasks/crm.py @@ -9,10 +9,11 @@ class CRMTaskSet(helper.BaseBackendTaskSet): def on_start(self, *args, **kwargs): - super(CRMTaskSet, self).on_start(*args, **kwargs) + res = super().on_start(*args, **kwargs) self.Lead = self.client.env["crm.lead"] self.Sale = self.client.env["sale.order"] self.Partner = self.client.env["res.partner"] + return res @task(20) def create_lead(self): diff --git a/odoo/tests/locust/tasks/project.py b/odoo/tests/locust/tasks/project.py index d3930ba..ffcbd76 100644 --- a/odoo/tests/locust/tasks/project.py +++ b/odoo/tests/locust/tasks/project.py @@ -8,7 +8,7 @@ class ProjectTaskSet(helper.BaseBackendTaskSet): def on_start(self, *args, **kwargs): - super(ProjectTaskSet, self).on_start(*args, **kwargs) + return super().on_start(*args, **kwargs) @task(10) def edit_task(self): diff --git a/odoo/tests/locust/tasks/purchase.py b/odoo/tests/locust/tasks/purchase.py index 9852458..13e249a 100644 --- a/odoo/tests/locust/tasks/purchase.py +++ b/odoo/tests/locust/tasks/purchase.py @@ -8,8 +8,9 @@ class PurchaseTaskSet(helper.BaseBackendTaskSet): def on_start(self, *args, **kwargs): - super(PurchaseTaskSet, self).on_start(*args, **kwargs) + res = super().on_start(*args, **kwargs) self.Purchase = self.client.env["purchase.order"] + return res @task(20) def create_new_rfq(self): diff --git a/odoo/tests/locust/tasks/sale.py b/odoo/tests/locust/tasks/sale.py index 3adc150..ac17164 100644 --- a/odoo/tests/locust/tasks/sale.py +++ b/odoo/tests/locust/tasks/sale.py @@ -9,9 +9,10 @@ class SaleTaskSet(helper.BaseBackendTaskSet): def on_start(self, *args, **kwargs): - super(SaleTaskSet, self).on_start(*args, **kwargs) + res = super().on_start(*args, **kwargs) self.Sale = self.client.env["sale.order"] self.now = datetime.now().strftime("%Y-%m-%d, %H:%M:%S") + return res @task(10) def create_sale_order(self): diff --git a/odoo/tests/locust/tasks/stock.py b/odoo/tests/locust/tasks/stock.py index 937cc33..e1018fd 100644 --- a/odoo/tests/locust/tasks/stock.py +++ b/odoo/tests/locust/tasks/stock.py @@ -8,8 +8,9 @@ class StockTaskSet(helper.BaseBackendTaskSet): def on_start(self, *args, **kwargs): - super(StockTaskSet, self).on_start(*args, **kwargs) + res = super().on_start(*args, **kwargs) self.Task = self.client.env["project.task"] + return res @task(10) def edit_delivery_lines(self): diff --git a/odoo/tests/selenium/README.md b/odoo/tests/selenium/README.md index e8feca9..06e7fb4 100644 --- a/odoo/tests/selenium/README.md +++ b/odoo/tests/selenium/README.md @@ -2,46 +2,59 @@ ## Installation -* Run +- Run + ```shell script python3 -m venv env . env/bin/activate pip install -r requirements.txt ``` -* Download Selenium IDE from the [Selenium website](https://www.selenium.dev/selenium-ide). - Choose the Chrome or Firefox version based on your web browser of choice + +- Download Selenium IDE from the + [Selenium website](https://www.selenium.dev/selenium-ide). Choose the Chrome or + Firefox version based on your web browser of choice ## Configuration -The Selenium tests require a database without previous test data. -If data from previous Selenium tests are found, the tests will fail. +The Selenium tests require a database without previous test data. If data from previous +Selenium tests are found, the tests will fail. ## Writing Tests in IDE -* At the top left, near the run buttons, select the plus (+) sign to create a new test in the project -* At the top right, select the "Rec" button (rec circle) to begin recording a workflow -* A new browser window will open. Selenium will record your actions as you perform each step of the workflow -* When the workflow is complete, return to the Selenium window and select the Stop button (replaces Rec button) -* The Selenium tests require unique identifiers for each webpage element it interacts with. +- At the top left, near the run buttons, select the plus (+) sign to create a new test + in the project +- At the top right, select the "Rec" button (rec circle) to begin recording a workflow +- A new browser window will open. Selenium will record your actions as you perform each + step of the workflow +- When the workflow is complete, return to the Selenium window and select the Stop + button (replaces Rec button) +- The Selenium tests require unique identifiers for each webpage element it interacts + with. - * Many of the default Targets selected by the recording will need to be modified to ensure that they are truly unique - * This typically includes replacing any use of indices (e.g. "//ul[2]") - * This may require referring to a parent element first, then the desired element by inheritance + - Many of the default Targets selected by the recording will need to be modified to + ensure that they are truly unique + - This typically includes replacing any use of indices (e.g. "//ul[2]") + - This may require referring to a parent element first, then the desired element by + inheritance -* It may be helpful to include assertions during the test to check if things are going well +- It may be helpful to include assertions during the test to check if things are going + well - * Right click on an existing step and select "Insert new command" - * See the `Selenium Command API `_ for more details + - Right click on an existing step and select "Insert new command" + - See the + `Selenium Command API `\_ + for more details -* Save the test when it is complete, and take it for a test run +- Save the test when it is complete, and take it for a test run ## Running Tests Manually through IDE -* Click on the Se extension icon in the top right of your browser window -* Select "Open an existing project" -* Select a `.side` file from this directory -* Near the top left of the Selenium popup window, there are two Triangular ("Play") buttons. - Select the left button with lines to run all tests, or run a test individually with the second button +- Click on the Se extension icon in the top right of your browser window +- Select "Open an existing project" +- Select a `.side` file from this directory +- Near the top left of the Selenium popup window, there are two Triangular ("Play") + buttons. Select the left button with lines to run all tests, or run a test + individually with the second button ## Interpreting Results @@ -56,6 +69,8 @@ the Odoo error popup to indicate what went wrong. ## Exporting Tests to Python -* In the Selenium IDE window, click the three dots (...) next to the test name on the left. -* Select Export. -* Choose Python pytest, export the test as a .py file and save it in the `tests` directory. +- In the Selenium IDE window, click the three dots (...) next to the test name on the + left. +- Select Export. +- Choose Python pytest, export the test as a .py file and save it in the `tests` + directory. diff --git a/requirements.txt b/requirements.txt index 6349c5c..ff66306 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -git-aggregator==1.7.2 -markdown-toc==1.2.6 -pre-commit==2.2.0 +git-aggregator +markdown-toc +pre-commit