# -*- coding: utf-8 -*- from odoo import SUPERUSER_ID from odoo.api import Environment #from . import import_machine_products import logging _logger = logging.getLogger(__name__) def run_migration(cr, registry): """ Wird nach der Modulinstallation automatisch ausgeführt. Migriert vorhandene res.partner-Einträge zu ows.user. """ env = Environment(cr, SUPERUSER_ID, {}) _logger.info("[OWS] Starte automatische Partner-Migration bei Modulinstallation...") try: env['res.partner'].migrate_existing_partners() _logger.info("[OWS] Automatische Partner-Migration abgeschlossen.") except Exception as e: _logger.error(f"[OWS] Fehler bei automatischer Partner-Migration: {e}") try: env['res.partner'].migrate_machine_access_from_old_fields() _logger.info("[OWS] Automatische Felder-Migration für Maschinenfreigaben in res.partner.") except Exception as e: _logger.error(f"[OWS] Fehler bei automatischer Felder-Migration: {e}") #import_machine_products.run_import(cr, registry) ''' Funktioniert nicht: try: module = env['ir.module.module'].search([('name', '=', 'vvow_einweisungen')], limit=1) if module and module.state != 'uninstalled': _logger.info("[OWS] Deinstalliere altes Modul vvow_einweisungen...") module.button_immediate_uninstall() except Exception as e: _logger.error(f"[OWS] Fehler bei deinstallieren von vvow_einweisungen: {e}") '''