From 42faa68903f2ba8be1f7e135bde23ae6e7c7f279 Mon Sep 17 00:00:00 2001 From: gitea Date: Sat, 12 Apr 2025 08:04:30 +0000 Subject: [PATCH] alter table vvow_einweisungen --- .../odoo-restore-open_workshop_install.yaml | 3 +-- scripts/uninstall_vvow_einweisungen.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/odoo-restore-open_workshop_install.yaml b/.gitea/workflows/odoo-restore-open_workshop_install.yaml index 921e6e0..4ab2a23 100644 --- a/.gitea/workflows/odoo-restore-open_workshop_install.yaml +++ b/.gitea/workflows/odoo-restore-open_workshop_install.yaml @@ -166,8 +166,7 @@ jobs: - name: Modul vvow_einweisungen deinstallieren run: | docker exec odoo_uninstall \ - /opt/odoo/odoo/odoo-bin shell -d ${{ env.DB_NAME }} \ - < /home/odoo/custom_addons/open_workshop/scripts/uninstall_vvow_einweisungen.py + /opt/odoo/odoo/odoo-bin shell -d ${{ env.DB_NAME }} < /home/odoo/custom_addons/open_workshop/scripts/uninstall_vvow_einweisungen.py - name: Stoppe temporären Container run: docker stop odoo_uninstall diff --git a/scripts/uninstall_vvow_einweisungen.py b/scripts/uninstall_vvow_einweisungen.py index 6121c5d..0410d0e 100644 --- a/scripts/uninstall_vvow_einweisungen.py +++ b/scripts/uninstall_vvow_einweisungen.py @@ -19,16 +19,25 @@ modules_to_uninstall = [ ] with api.Environment.manage(): - registry = Registry("hobbyhimmel") # Wird beim Shell-Aufruf überschrieben + registry = Registry("hobbyhimmel") # wird beim odoo-bin shell überschrieben with registry.cursor() as cr: env = api.Environment(cr, SUPERUSER_ID, {}) + # 🛠 Versuch, FK-Constraint manuell zu entfernen (vorheriger Fehlerursache) + try: + cr.execute(""" + ALTER TABLE res_partner DROP CONSTRAINT IF EXISTS res_partner_vvow_document_id_fkey + """) + print("✅ Foreign Key 'res_partner_vvow_document_id_fkey' erfolgreich (oder schon) entfernt.") + except Exception as e: + print(f"⚠️ Konnte FK nicht entfernen: {e}") + for module_name in modules_to_uninstall: module = env['ir.module.module'].search([('name', '=', module_name)], limit=1) if module and module.state == 'installed': - print(f"Uninstalling module: {module_name}") + print(f"📦 Deinstalliere Modul: {module_name}") module.button_immediate_uninstall() else: - print(f"Module not found or not installed: {module_name}") + print(f"ℹ️ Modul nicht gefunden oder nicht installiert: {module_name}") - cr.commit() \ No newline at end of file + cr.commit()