From 7f827cf7eb93f2684ebf7439523549de5f9ee6e9 Mon Sep 17 00:00:00 2001 From: "matthias.lotz" Date: Wed, 28 Jan 2026 18:55:55 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20POS-Funktionalit=C3=A4t=20in=20open=5Fwo?= =?UTF-8?q?rkshop=5Fpos=20verschoben=20+=20Workarounds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- open_workshop_pos/__init__.py | 1 + open_workshop_pos/__manifest__.py | 2 + open_workshop_pos/hooks.py | 46 +++++++++++++++++++ open_workshop_pos/models/__init__.py | 2 +- .../models/pos_order.py | 0 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 open_workshop_pos/hooks.py rename {open_workshop_base => open_workshop_pos}/models/pos_order.py (100%) diff --git a/open_workshop_pos/__init__.py b/open_workshop_pos/__init__.py index a0fdc10..ab4d630 100644 --- a/open_workshop_pos/__init__.py +++ b/open_workshop_pos/__init__.py @@ -1,2 +1,3 @@ # -*- coding: utf-8 -*- from . import models +from .hooks import post_init_hook diff --git a/open_workshop_pos/__manifest__.py b/open_workshop_pos/__manifest__.py index f39bcd5..43018f6 100644 --- a/open_workshop_pos/__manifest__.py +++ b/open_workshop_pos/__manifest__.py @@ -27,6 +27,7 @@ Autor: HobbyHimmel 'depends': [ 'open_workshop_base', 'point_of_sale', + 'l10n_de', # Kontenplan für Deutschland (erstellt Bankjournal für POS Demo-Daten) ], 'data': [ # Views @@ -62,4 +63,5 @@ Autor: HobbyHimmel 'installable': True, 'application': False, 'auto_install': False, + 'post_init_hook': 'post_init_hook', } diff --git a/open_workshop_pos/hooks.py b/open_workshop_pos/hooks.py new file mode 100644 index 0000000..7939a66 --- /dev/null +++ b/open_workshop_pos/hooks.py @@ -0,0 +1,46 @@ +# -*- 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") diff --git a/open_workshop_pos/models/__init__.py b/open_workshop_pos/models/__init__.py index f234647..9e9e7ad 100644 --- a/open_workshop_pos/models/__init__.py +++ b/open_workshop_pos/models/__init__.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -# POS-spezifische Modelle (falls benötigt) +from . import pos_order diff --git a/open_workshop_base/models/pos_order.py b/open_workshop_pos/models/pos_order.py similarity index 100% rename from open_workshop_base/models/pos_order.py rename to open_workshop_pos/models/pos_order.py