diff --git a/open_workshop/__init__.py b/open_workshop/__init__.py deleted file mode 100644 index d7af4f2..0000000 --- a/open_workshop/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from . import models -from . import controllers - diff --git a/open_workshop/Checkliste.md b/open_workshop_base/Checkliste.md similarity index 100% rename from open_workshop/Checkliste.md rename to open_workshop_base/Checkliste.md diff --git a/open_workshop/LICENSE b/open_workshop_base/LICENSE similarity index 100% rename from open_workshop/LICENSE rename to open_workshop_base/LICENSE diff --git a/open_workshop/README.md b/open_workshop_base/README.md similarity index 100% rename from open_workshop/README.md rename to open_workshop_base/README.md diff --git a/open_workshop_base/__init__.py b/open_workshop_base/__init__.py new file mode 100644 index 0000000..b613e69 --- /dev/null +++ b/open_workshop_base/__init__.py @@ -0,0 +1,56 @@ +from . import models +from . import controllers + + +def post_init_hook(env): + """ + Migration Hook: open_workshop → open_workshop_base + Wird automatisch nach der Installation/Update des Moduls ausgeführt + """ + cr = env.cr + + # Prüfen ob altes Modul 'open_workshop' in DB existiert + cr.execute(""" + SELECT id FROM ir_module_module + WHERE name = 'open_workshop' AND id != ( + SELECT id FROM ir_module_module WHERE name = 'open_workshop_base' + ) + """) + + if cr.fetchone(): + import logging + _logger = logging.getLogger(__name__) + + _logger.info("=" * 70) + _logger.info("MIGRATION: Renaming module 'open_workshop' to 'open_workshop_base'") + _logger.info("=" * 70) + + # Modulnamen aktualisieren + cr.execute(""" + UPDATE ir_module_module + SET name = 'open_workshop_base' + WHERE name = 'open_workshop' + """) + _logger.info(f"✓ Updated ir_module_module: {cr.rowcount} row(s)") + + # ir_model_data Referenzen aktualisieren + cr.execute(""" + UPDATE ir_model_data + SET module = 'open_workshop_base' + WHERE module = 'open_workshop' + """) + _logger.info(f"✓ Updated ir_model_data: {cr.rowcount} row(s)") + + # Abhängigkeiten aktualisieren + cr.execute(""" + UPDATE ir_module_module_dependency + SET name = 'open_workshop_base' + WHERE name = 'open_workshop' + """) + if cr.rowcount > 0: + _logger.info(f"✓ Updated dependencies: {cr.rowcount} row(s)") + + _logger.info("=" * 70) + _logger.info("MIGRATION COMPLETED") + _logger.info("=" * 70) + diff --git a/open_workshop/__manifest__.py b/open_workshop_base/__manifest__.py similarity index 51% rename from open_workshop/__manifest__.py rename to open_workshop_base/__manifest__.py index e9b211f..27ca633 100644 --- a/open_workshop/__manifest__.py +++ b/open_workshop_base/__manifest__.py @@ -1,7 +1,7 @@ { - 'name': 'POS Open Workshop', + 'name': 'Open Workshop Base', 'license': 'AGPL-3', - 'version': '18.0.1.0.2', + 'version': '18.0.1.0.3', 'summary': 'Erstellt Maschinenfreigaben basierend auf POS-Einweisungsprodukten', 'depends': ['base', 'account', 'hr','product','sale','contacts','point_of_sale'], 'author': 'matthias.lotz', @@ -19,22 +19,23 @@ 'installable': True, 'assets': { 'web.assets_backend': [ - 'open_workshop/static/src/css/category_color.css', + 'open_workshop_base/static/src/css/category_color.css', ], 'point_of_sale._assets_pos': [ - 'open_workshop/static/src/css/pos.css', - 'open_workshop/static/src/js/ows_machine_access_list.js', - 'open_workshop/static/src/js/ows_pos_customer_sidebar.js', - 'open_workshop/static/src/js/ows_pos_sidebar.js', - 'open_workshop/static/src/js/ows_product_screen_template_patch.js', - 'open_workshop/static/src/xml/ows_machine_access_list.xml', - 'open_workshop/static/src/xml/ows_pos_customer_sidebar.xml', - 'open_workshop/static/src/xml/ows_pos_sidebar.xml', - 'open_workshop/static/src/xml/ows_product_screen_template_patch.xml', + 'open_workshop_base/static/src/css/pos.css', + 'open_workshop_base/static/src/js/ows_machine_access_list.js', + 'open_workshop_base/static/src/js/ows_pos_customer_sidebar.js', + 'open_workshop_base/static/src/js/ows_pos_sidebar.js', + 'open_workshop_base/static/src/js/ows_product_screen_template_patch.js', + 'open_workshop_base/static/src/xml/ows_machine_access_list.xml', + 'open_workshop_base/static/src/xml/ows_pos_customer_sidebar.xml', + 'open_workshop_base/static/src/xml/ows_pos_sidebar.xml', + 'open_workshop_base/static/src/xml/ows_product_screen_template_patch.xml', ], }, 'description': """ Diese App erstellt Maschinenfreigaben basierend auf POS-Einweisungsprodukten. Die App ist für den Einsatz in der Odoo-Version 18.0 konzipiert. """, + 'post_init_hook': 'post_init_hook', } diff --git a/open_workshop/controllers/__init__.py b/open_workshop_base/controllers/__init__.py similarity index 100% rename from open_workshop/controllers/__init__.py rename to open_workshop_base/controllers/__init__.py diff --git a/open_workshop/controllers/pos_access.py b/open_workshop_base/controllers/pos_access.py similarity index 100% rename from open_workshop/controllers/pos_access.py rename to open_workshop_base/controllers/pos_access.py diff --git a/open_workshop/data/data.xml b/open_workshop_base/data/data.xml similarity index 100% rename from open_workshop/data/data.xml rename to open_workshop_base/data/data.xml diff --git a/open_workshop_base/migrations/18.0.1.0.3/pre-migrate.py b/open_workshop_base/migrations/18.0.1.0.3/pre-migrate.py new file mode 100644 index 0000000..7019b06 --- /dev/null +++ b/open_workshop_base/migrations/18.0.1.0.3/pre-migrate.py @@ -0,0 +1,64 @@ +# Migration: open_workshop → open_workshop_base +# Dieses Skript wird automatisch vor dem Modul-Update ausgeführt + +import logging + +_logger = logging.getLogger(__name__) + + +def migrate(cr, version): + """ + Benennt das Modul 'open_workshop' in 'open_workshop_base' um. + + Wichtig: + - Modellnamen (_name) bleiben unverändert (z.B. 'ows.machine') + - Tabellennamen bleiben unverändert + - Keine Datenmigration erforderlich + - Nur Modul-Metadaten werden aktualisiert + + Dieses Skript läuft VOR dem normalen Update-Prozess. + """ + + # Prüfen ob altes Modul existiert + cr.execute(""" + SELECT id, state FROM ir_module_module + WHERE name = 'open_workshop' + """) + old_module = cr.fetchone() + + if old_module: + _logger.info("=" * 70) + _logger.info("MIGRATION: Renaming module 'open_workshop' to 'open_workshop_base'") + _logger.info("=" * 70) + + # 1. Modulnamen in ir_module_module aktualisieren + cr.execute(""" + UPDATE ir_module_module + SET name = 'open_workshop_base' + WHERE name = 'open_workshop' + """) + _logger.info(f"✓ Updated ir_module_module: {cr.rowcount} row(s)") + + # 2. Alle ir_model_data Referenzen aktualisieren + cr.execute(""" + UPDATE ir_model_data + SET module = 'open_workshop_base' + WHERE module = 'open_workshop' + """) + _logger.info(f"✓ Updated ir_model_data: {cr.rowcount} row(s)") + + # 3. Abhängigkeiten in anderen Modulen aktualisieren (falls vorhanden) + cr.execute(""" + UPDATE ir_module_module_dependency + SET name = 'open_workshop_base' + WHERE name = 'open_workshop' + """) + if cr.rowcount > 0: + _logger.info(f"✓ Updated dependencies in other modules: {cr.rowcount} row(s)") + + _logger.info("=" * 70) + _logger.info("MIGRATION COMPLETED: Module successfully renamed") + _logger.info("Note: Model names (e.g., 'ows.machine') remain unchanged") + _logger.info("=" * 70) + else: + _logger.info("INFO: Module 'open_workshop' not found - migration not needed") diff --git a/open_workshop_base/migrations/migrate_open_workshop_to_base.sql b/open_workshop_base/migrations/migrate_open_workshop_to_base.sql new file mode 100644 index 0000000..42759be --- /dev/null +++ b/open_workshop_base/migrations/migrate_open_workshop_to_base.sql @@ -0,0 +1,98 @@ +-- ============================================================================ +-- Pre-Deployment Migration Script: open_workshop → open_workshop_base +-- ============================================================================ +-- Dieses SQL-Skript MUSS vor dem Odoo-Update in der Gitea Action ausgeführt werden +-- +-- Verwendung in Gitea Action: +-- docker exec psql -U odoo -d < migrate_open_workshop_to_base.sql +-- +-- Oder als Deployment-Hook vor "odoo -u open_workshop_base" +-- ============================================================================ + +\echo '==========================================' +\echo 'Migration: open_workshop → open_workshop_base' +\echo '==========================================' + +-- Prüfen ob Migration nötig ist +DO $$ +DECLARE + old_module_exists BOOLEAN; + new_module_exists BOOLEAN; +BEGIN + -- Prüfe ob altes Modul existiert + SELECT EXISTS( + SELECT 1 FROM ir_module_module WHERE name = 'open_workshop' + ) INTO old_module_exists; + + -- Prüfe ob neues Modul bereits existiert + SELECT EXISTS( + SELECT 1 FROM ir_module_module WHERE name = 'open_workshop_base' + ) INTO new_module_exists; + + IF old_module_exists THEN + RAISE NOTICE '✓ Found module "open_workshop" - starting migration'; + + IF new_module_exists THEN + RAISE NOTICE '⚠ Module "open_workshop_base" already exists - cleaning up'; + -- Aufräumen falls Testinstallation vorhanden + DELETE FROM ir_model_data WHERE module = 'base' AND name = 'module_open_workshop_base'; + DELETE FROM ir_module_module WHERE name = 'open_workshop_base'; + END IF; + + -- ===== MIGRATION DURCHFÜHREN ===== + + -- 1. Modulnamen aktualisieren + UPDATE ir_module_module + SET name = 'open_workshop_base' + WHERE name = 'open_workshop'; + + RAISE NOTICE '✓ Updated ir_module_module: % row(s)', (SELECT 1); + + -- 2. Alle ir_model_data Referenzen aktualisieren + UPDATE ir_model_data + SET module = 'open_workshop_base' + WHERE module = 'open_workshop'; + + RAISE NOTICE '✓ Updated ir_model_data: % row(s)', ( + SELECT COUNT(*) FROM ir_model_data WHERE module = 'open_workshop_base' + ); + + -- 3. Abhängigkeiten in anderen Modulen aktualisieren (falls vorhanden) + UPDATE ir_module_module_dependency + SET name = 'open_workshop_base' + WHERE name = 'open_workshop'; + + IF FOUND THEN + RAISE NOTICE '✓ Updated dependencies in other modules'; + END IF; + + RAISE NOTICE '=========================================='; + RAISE NOTICE '✓ MIGRATION COMPLETED SUCCESSFULLY'; + RAISE NOTICE '=========================================='; + RAISE NOTICE 'Next step: Run "odoo -u open_workshop_base -d "'; + + ELSE + RAISE NOTICE 'ℹ Module "open_workshop" not found - migration not needed'; + RAISE NOTICE 'This is normal for new installations'; + END IF; + +EXCEPTION + WHEN OTHERS THEN + RAISE EXCEPTION 'Migration failed: %', SQLERRM; +END +$$; + +-- Prüfung: Zeige aktuellen Status +\echo '' +\echo 'Current module status:' +SELECT name, state, latest_version +FROM ir_module_module +WHERE name LIKE 'open_workshop%' +ORDER BY name; + +\echo '' +\echo 'Model data count:' +SELECT module, COUNT(*) as entries +FROM ir_model_data +WHERE module LIKE 'open_workshop%' +GROUP BY module; diff --git a/open_workshop/models/__init__.py b/open_workshop_base/models/__init__.py similarity index 100% rename from open_workshop/models/__init__.py rename to open_workshop_base/models/__init__.py diff --git a/open_workshop/models/ows_models.py b/open_workshop_base/models/ows_models.py similarity index 100% rename from open_workshop/models/ows_models.py rename to open_workshop_base/models/ows_models.py diff --git a/open_workshop/models/pos_order.py b/open_workshop_base/models/pos_order.py similarity index 100% rename from open_workshop/models/pos_order.py rename to open_workshop_base/models/pos_order.py diff --git a/open_workshop/security/ir.model.access.csv b/open_workshop_base/security/ir.model.access.csv similarity index 100% rename from open_workshop/security/ir.model.access.csv rename to open_workshop_base/security/ir.model.access.csv diff --git a/open_workshop/static/src/css/category_color.css b/open_workshop_base/static/src/css/category_color.css similarity index 100% rename from open_workshop/static/src/css/category_color.css rename to open_workshop_base/static/src/css/category_color.css diff --git a/open_workshop/static/src/css/pos.css b/open_workshop_base/static/src/css/pos.css similarity index 100% rename from open_workshop/static/src/css/pos.css rename to open_workshop_base/static/src/css/pos.css diff --git a/open_workshop/static/src/js/ows_machine_access_list.js b/open_workshop_base/static/src/js/ows_machine_access_list.js similarity index 92% rename from open_workshop/static/src/js/ows_machine_access_list.js rename to open_workshop_base/static/src/js/ows_machine_access_list.js index f3ecc0f..6bcd0ee 100644 --- a/open_workshop/static/src/js/ows_machine_access_list.js +++ b/open_workshop_base/static/src/js/ows_machine_access_list.js @@ -7,7 +7,7 @@ import { rpc } from "@web/core/network/rpc"; import { registry } from "@web/core/registry"; export class OwsMachineAccessList extends Component { - static template = 'open_workshop.OwsMachineAccessList'; + static template = 'open_workshop_base.OwsMachineAccessList'; setup() { this.pos = usePos(); @@ -68,5 +68,5 @@ export class OwsMachineAccessList extends Component { -registry.category("templates").add("open_workshop.OwsMachineAccessList", OwsMachineAccessList); +registry.category("templates").add("open_workshop_base.OwsMachineAccessList", OwsMachineAccessList); diff --git a/open_workshop/static/src/js/ows_pos_customer_sidebar.js b/open_workshop_base/static/src/js/ows_pos_customer_sidebar.js similarity index 96% rename from open_workshop/static/src/js/ows_pos_customer_sidebar.js rename to open_workshop_base/static/src/js/ows_pos_customer_sidebar.js index b14b7b6..3c9e987 100644 --- a/open_workshop/static/src/js/ows_pos_customer_sidebar.js +++ b/open_workshop_base/static/src/js/ows_pos_customer_sidebar.js @@ -7,7 +7,7 @@ import { _t } from "@web/core/l10n/translation"; import { ask } from "@web/core/confirmation_dialog/confirmation_dialog"; export class OwsPosCustomerSidebar extends Component { - static template = "open_workshop.OwsPosCustomerSidebar"; + static template = "open_workshop_base.OwsPosCustomerSidebar"; setup() { this.pos = usePos(); // ✅ Holt dir Zugriff auf den zentralen POS-Store diff --git a/open_workshop/static/src/js/ows_pos_sidebar.js b/open_workshop_base/static/src/js/ows_pos_sidebar.js similarity index 85% rename from open_workshop/static/src/js/ows_pos_sidebar.js rename to open_workshop_base/static/src/js/ows_pos_sidebar.js index dfdc8e3..962fe7a 100644 --- a/open_workshop/static/src/js/ows_pos_sidebar.js +++ b/open_workshop_base/static/src/js/ows_pos_sidebar.js @@ -6,6 +6,6 @@ import { OwsPosCustomerSidebar } from "./ows_pos_customer_sidebar"; import { OwsMachineAccessList } from "./ows_machine_access_list"; export class OwsPosSidebar extends Component { - static template = "open_workshop.OwsPosSidebar"; + static template = "open_workshop_base.OwsPosSidebar"; static components = { OwsPosCustomerSidebar, OwsMachineAccessList }; } \ No newline at end of file diff --git a/open_workshop/static/src/js/ows_product_screen_template_patch.js b/open_workshop_base/static/src/js/ows_product_screen_template_patch.js similarity index 100% rename from open_workshop/static/src/js/ows_product_screen_template_patch.js rename to open_workshop_base/static/src/js/ows_product_screen_template_patch.js diff --git a/open_workshop/static/src/xml/ows_machine_access_list.xml b/open_workshop_base/static/src/xml/ows_machine_access_list.xml similarity index 98% rename from open_workshop/static/src/xml/ows_machine_access_list.xml rename to open_workshop_base/static/src/xml/ows_machine_access_list.xml index 787441b..0b2f64f 100644 --- a/open_workshop/static/src/xml/ows_machine_access_list.xml +++ b/open_workshop_base/static/src/xml/ows_machine_access_list.xml @@ -1,4 +1,4 @@ - +
diff --git a/open_workshop/static/src/xml/ows_pos_customer_sidebar.xml b/open_workshop_base/static/src/xml/ows_pos_customer_sidebar.xml similarity index 95% rename from open_workshop/static/src/xml/ows_pos_customer_sidebar.xml rename to open_workshop_base/static/src/xml/ows_pos_customer_sidebar.xml index 31f5e35..fc6a596 100644 --- a/open_workshop/static/src/xml/ows_pos_customer_sidebar.xml +++ b/open_workshop_base/static/src/xml/ows_pos_customer_sidebar.xml @@ -1,6 +1,6 @@ - +
diff --git a/open_workshop/static/src/xml/ows_pos_sidebar.xml b/open_workshop_base/static/src/xml/ows_pos_sidebar.xml similarity index 81% rename from open_workshop/static/src/xml/ows_pos_sidebar.xml rename to open_workshop_base/static/src/xml/ows_pos_sidebar.xml index 1777b19..5aa83dc 100644 --- a/open_workshop/static/src/xml/ows_pos_sidebar.xml +++ b/open_workshop_base/static/src/xml/ows_pos_sidebar.xml @@ -1,6 +1,6 @@ - +
diff --git a/open_workshop/static/src/xml/ows_product_screen_template_patch.xml b/open_workshop_base/static/src/xml/ows_product_screen_template_patch.xml similarity index 100% rename from open_workshop/static/src/xml/ows_product_screen_template_patch.xml rename to open_workshop_base/static/src/xml/ows_product_screen_template_patch.xml diff --git a/open_workshop/views/assets.xml b/open_workshop_base/views/assets.xml similarity index 61% rename from open_workshop/views/assets.xml rename to open_workshop_base/views/assets.xml index 2f88e74..8b9b79f 100644 --- a/open_workshop/views/assets.xml +++ b/open_workshop_base/views/assets.xml @@ -1,8 +1,8 @@