Files
computer-playbook/tests/unit/python/roles/web-app-odoo/test_addon_manifest_version.py
T
kevinveenbirkenbachandClaude Opus 5.5 c35f2409a4 fix(web-app-odoo): make the OAuth addon work on Odoo 20
Nobody could sign in to Odoo through Keycloak. Odoo sent an http redirect
URI, and Keycloak refused it as "Invalid parameter: redirect_uri".

The addon auth_oauth_https builds that URI from web.base.url. Two things
kept it from doing so after the image moved to Odoo 20.

Its manifest declared version 19.0.1.8.0, and Odoo marks a module whose
version names another series as not installable. It only warns about that,
so the install task stayed green and the addon was missing. The manifest
now declares 1.8.0, which Odoo prefixes with its own series.

Once installed, the addon read the parameter with get_param, which Odoo 20
replaced by typed getters. The call raised AttributeError, a broad except
logged it and fell back to the URL of the request, which is http behind
the proxy. The addon reads the parameter with get_str now and no longer
catches the error.

A deploy now fails when the addon is not installed afterwards. The check
reads ir_module_module, because the output of "odoo -i" does not tell an
installed module from a skipped one.

The spec logged out by navigating to /web/session/logout. Odoo 20 accepts
POST only on that route and answered 405, so both SSO tests failed after
a successful login. The spec logs out through the user menu now.

A host that runs the suite with several workers still failed it. Odoo
computes the session token of an account from its OAuth access token, so
every new sign-in ends the other sessions of that account, and the spec
files share the administrator. The role caps its suite at one worker
with PLAYWRIGHT_MAX_WORKERS, which the central config now honours, and
the spec asserts the cap.

Closes #822

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 11:37:41 +02:00

44 lines
1.4 KiB
Python

from __future__ import annotations
import ast
import unittest
from utils.cache.files import PROJECT_ROOT, read_text
MANIFEST = (
PROJECT_ROOT / "roles/web-app-odoo/files/addons/auth_oauth_https/__manifest__.py"
)
def manifest_version() -> str:
return ast.literal_eval(read_text(str(MANIFEST)))["version"]
def installable_on(series: str, version: str) -> bool:
parts = version.split(".")
if not 2 <= len(parts) <= 5 or not all(part.isdigit() for part in parts):
return False
if len(parts) <= 3 and not version.startswith(series):
version = f"{series}.{version}"
return version.startswith(series + ".")
class TestAddonManifestVersion(unittest.TestCase):
def test_odoo_installs_the_addon_on_every_series(self):
for series in ("19.0", "20.0", "21.0"):
with self.subTest(series=series):
self.assertTrue(
installable_on(series, manifest_version()),
f"Odoo {series} marks a module whose version names another "
"series as not installable and only warns about it; keep the "
"version in the form x.y.z so Odoo prefixes its own series",
)
def test_a_version_that_names_a_series_is_refused_by_the_next_one(self):
self.assertTrue(installable_on("19.0", "19.0.1.8.0"))
self.assertFalse(installable_on("20.0", "19.0.1.8.0"))
if __name__ == "__main__":
unittest.main()