added option custom_addon in config.yaml

This commit is contained in:
Matthias Lotz 2025-05-27 07:52:50 +02:00
parent a362783e6d
commit a34d880721
6 changed files with 90 additions and 3 deletions

23
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,23 @@
{
// Verwendet IntelliSense zum Ermitteln möglicher Attribute.
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python-Debugger: Remoteanfügung",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/home/lotzm/odoo-openupgrade-wizard"
}
]
}
]
}

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"python.defaultInterpreterPath": "/home/lotzm/.local/share/pipx/venvs/odoo-openupgrade-wizard/bin/python"
}

19
PATCH.md Normal file
View File

@ -0,0 +1,19 @@
# Loakale Entwicklung an oow
Das geht am einfachsten mit **pipx** im "editable mode" (`--editable`), sodass Änderungen im Arbeitsverzeichnis sofort wirksam sind.
Angenommen, dein Arbeitsverzeichnis ist odoo-openupgrade-wizard, dann führe im Terminal aus:
```bash
pipx install --editable /home/lotzm/odoo-openupgrade-wizard
```
Dadurch wird ein Symlink auf dein Arbeitsverzeichnis erstellt und du kannst direkt am Code arbeiten.
Das Kommando `oow` ist dann wie gewohnt verfügbar, aber nutzt immer den aktuellen Stand deines Codes.
**Hinweis:**
Falls du vorher schon eine pipx-Installation hattest, führe vorher aus:
```bash
pipx uninstall odoo-openupgrade-wizard
```
Danach kannst du Änderungen im Arbeitsverzeichnis machen und direkt testen!

View File

@ -1,3 +1,10 @@
import debugpy
#debugpy.listen(("0.0.0.0", 5678))
#print("⏳ Warten auf Debugger-Anbindung (VS Code: Python: Remote Attach)...")
#debugpy.wait_for_client()
#print("✅ Debugger verbunden!")
import datetime
import logging
import sys

View File

@ -88,14 +88,33 @@ def get_odoo_addons_path(
def is_addons_path(ctx, path: Path, migration_step: dict):
logger.debug(f"Untersuche Pfad: {path}")
for folder in [x for x in path.iterdir() if x.is_dir()]:
logger.debug(f" Untersuche Pfad: {folder}")
if (folder / "__init__.py").exists() and (
folder / get_manifest_name(migration_step)
).exists():
logger.info(f" ✔️ Odoo-Modul gefunden in: {folder}")
return True
return False
#def is_addons_path(ctx, path: Path, migration_step: dict):
# """Prüft, ob im Verzeichnis mindestens ein Odoo-Modul liegt."""
# logger.debug(f"Untersuche Pfad: {path}")
# for folder in path.iterdir():
# if folder.is_dir():
# init_exists = (folder / "__init__.py").exists()
# manifest_path = folder / get_manifest_name(migration_step)
# manifest_exists = manifest_path.exists()
# logger.debug(
# f" Untersuche Unterordner: {folder} | __init__.py: {init_exists}, Manifest: {manifest_path.name}: {manifest_exists}"
# )
# if init_exists and manifest_exists:
# logger.info(f" ✔️ Odoo-Modul gefunden in: {folder}")
# return True
# return False
def get_odoo_env_path(ctx, odoo_version: float) -> Path:
folder_name = "env_%s" % str(odoo_version).rjust(4, "0")
return ctx.obj["src_folder_path"] / folder_name
@ -132,7 +151,7 @@ def generate_odoo_command_options(
stop_after_init: bool = False,
) -> list:
"""
Generate Odoo command options as a list of string to append to any command.
Generate Odoo command options as a list of strings to append to any command.
"""
odoo_env_path = get_odoo_env_path(ctx, migration_step["version"])
@ -151,6 +170,18 @@ def generate_odoo_command_options(
addons_path_list, empty_addons_path_list = get_odoo_addons_path(
ctx, odoo_env_path, migration_step, execution_context
)
# custom_addons from odoo_version_settings[version]
version = migration_step["version"]
#TODO: check if custom_addons is in ctx.obj['config']
custom_addons = ctx.obj.get("config", {}).get("odoo_version_settings", {}).get(version, {}).get("custom_addons", [])
for path in custom_addons:
logger.info(f"📁 custom_addons: adding path '{path}'")
addons_path_list.append(path)
# Normalize addons path (relative to /odoo_env in container)
addons_path = ",".join(
[str(Path("/odoo_env") / x) for x in addons_path_list]
)
@ -186,7 +217,10 @@ def generate_odoo_command_options(
f"{'--stop-after-init' if stop_after_init else ''}",
]
# remove empty strings
# Log resolved addons_path
logger.info(f"📦 Final --addons-path: {addons_path}")
# Remove empty strings
return [x for x in options if x]

View File

@ -1,6 +1,6 @@
[project]
name = "odoo-openupgrade-wizard"
version = "1.3.0"
version = "1.3.2"
description = "CLI tool to manage Odoo Major Upgrades"
authors = [
{name = "Sylvain LE GAL", email = "sylvain.legal@grap.coop"},
@ -63,6 +63,7 @@ safety = "*"
pylint = "*"
tox = "*"
towncrier = "*"
debugpy = "*"
[build-system]
requires = ["poetry-core>=1.0.0"]