From 3b35a56ca18ddb292c1398f6fb3083af5acf642a Mon Sep 17 00:00:00 2001 From: gitea Date: Thu, 10 Apr 2025 16:52:35 +0000 Subject: [PATCH] added uninstall scripts --- scripts/fix_missing_pos_partner.py | 3 +- scripts/uninstall_vvow_einweisungen.py | 35 +++++++++++++++++++ ...l_old_modules.py => uninstall_vvow_pos.py} | 2 +- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 scripts/uninstall_vvow_einweisungen.py rename scripts/{uninstall_old_modules.py => uninstall_vvow_pos.py} (92%) diff --git a/scripts/fix_missing_pos_partner.py b/scripts/fix_missing_pos_partner.py index c3d7bac..7e95648 100644 --- a/scripts/fix_missing_pos_partner.py +++ b/scripts/fix_missing_pos_partner.py @@ -37,4 +37,5 @@ def fix_missing_pos_order_partners(cr, registry): # Automatischer Start in odoo-bin shell if 'env' in globals(): - fix_missing_pos_order_partners(env.cr, env.registry) \ No newline at end of file + fix_missing_pos_order_partners(env.cr, env.registry) + env.cr.commit() \ No newline at end of file diff --git a/scripts/uninstall_vvow_einweisungen.py b/scripts/uninstall_vvow_einweisungen.py new file mode 100644 index 0000000..88ccfb8 --- /dev/null +++ b/scripts/uninstall_vvow_einweisungen.py @@ -0,0 +1,35 @@ +# scripts/uninstall_old_modules.py +# odoo-bin -d deine_datenbank -i open_workshop --load-script=scripts/uninstall_old_modules.py + +''' +- name: Uninstall old modules + run: | + odoo-bin -d hobbyhimmel --load-script=scripts/uninstall_old_modules.py + +- name: Install open_workshop + run: | + odoo-bin -d hobbyhimmel -u open_workshop +''' + + +from odoo import api, SUPERUSER_ID +from odoo.modules.registry import Registry + +modules_to_uninstall = [ + 'vvow_einweisungen' +] + +with api.Environment.manage(): + registry = Registry("hobbyhimmel") # Wird beim Shell-Aufruf überschrieben + with registry.cursor() as cr: + env = api.Environment(cr, SUPERUSER_ID, {}) + + 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}") + module.button_immediate_uninstall() + else: + print(f"Module not found or not installed: {module_name}") + + cr.commit() \ No newline at end of file diff --git a/scripts/uninstall_old_modules.py b/scripts/uninstall_vvow_pos.py similarity index 92% rename from scripts/uninstall_old_modules.py rename to scripts/uninstall_vvow_pos.py index 3be99c0..4bfe182 100644 --- a/scripts/uninstall_old_modules.py +++ b/scripts/uninstall_vvow_pos.py @@ -20,7 +20,7 @@ modules_to_uninstall = [ ] with api.Environment.manage(): - registry = Registry("__db__") # Wird beim Shell-Aufruf überschrieben + registry = Registry("hobbyhimmel") # Wird beim Shell-Aufruf überschrieben with registry.cursor() as cr: env = api.Environment(cr, SUPERUSER_ID, {})