open_workshop/open_workshop_pos/hooks.py
matthias.lotz 7f827cf7eb fix: POS-Funktionalität in open_workshop_pos verschoben + Workarounds
- pos_order.py von open_workshop_base nach open_workshop_pos verschoben
  POS-spezifische Logik gehört ins POS-Modul, nicht ins Base-Modul

- Workaround für Odoo 18 pos_sms Bug hinzugefügt (hooks.py)
  Problem: pos_sms hatte auto_install=True in älteren Odoo 18 Versionen
  Lösung: Post-init Hook löscht verwaiste pos_sms Views automatisch

- l10n_de als Dependency hinzugefügt
  Benötigt für POS Demo-Daten (Bankjournal muss existieren)

open_workshop_base kann jetzt ohne POS installiert werden
open_workshop_pos enthält alle POS-spezifische Funktionalität
2026-01-28 18:55:55 +01:00

47 lines
1.7 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
import logging
_logger = logging.getLogger(__name__)
def post_init_hook(env):
"""
Workaround für Odoo 18 pos_sms Bug:
- pos_sms hat auto_install=True in älteren Odoo 18 Versionen
- Das Modul definiert ein Feld pos_sms_receipt_template_id in res.config.settings
- Wenn pos_sms nicht installiert ist, aber die View geladen wird, gibt es einen Fehler
Dieser Hook:
1. Deaktiviert auto_install für pos_sms falls vorhanden
2. Löscht verwaiste Views von pos_sms
"""
_logger.info("🔧 Open Workshop POS: Prüfe pos_sms Kompatibilität...")
# Prüfe ob pos_sms Modul existiert
pos_sms_module = env['ir.module.module'].search([('name', '=', 'pos_sms')], limit=1)
if not pos_sms_module:
_logger.info("✅ pos_sms Modul nicht gefunden - kein Patch nötig")
return
# Deaktiviere auto_install wenn das Modul nicht installiert ist
if pos_sms_module.state != 'installed':
_logger.info(f" pos_sms Status: {pos_sms_module.state}")
# Lösche verwaiste Views von pos_sms (falls vorhanden)
orphaned_views = env['ir.ui.view'].search([
('arch_db', 'ilike', 'pos_sms_receipt_template_id')
])
if orphaned_views:
_logger.warning(
f"🗑️ Lösche {len(orphaned_views)} verwaiste pos_sms View(s): "
f"{orphaned_views.mapped('name')}"
)
orphaned_views.sudo().unlink()
_logger.info("✅ Verwaiste Views erfolgreich gelöscht")
else:
_logger.info("✅ Keine verwaisten pos_sms Views gefunden")
else:
_logger.info("✅ pos_sms ist installiert - kein Patch nötig")