open_workshop/post_init_hook.py

27 lines
976 B
Python

# -*- coding: utf-8 -*-
from odoo import SUPERUSER_ID
from odoo.api import Environment
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}")