Migration: open_workshop → open_workshop_base

- Modul umbenannt von open_workshop zu open_workshop_base
- Alle Referenzen im Code aktualisiert (Templates, Views, Assets)
- SQL-Migrationsskript für automatische DB-Migration erstellt
- post_init_hook hinzugefügt
- Version auf 18.0.1.0.3 erhöht
- Vorbereitung für modulare Architektur (Base, POS, API)

Fixes für Gitea Action Integration:
- SQL-Skript in open_workshop_base/migrations/
- Alter open_workshop/ Ordner entfernt
- Migrations-Workflow getestet auf hh18
This commit is contained in:
Matthias Lotz 2025-12-07 15:45:03 +01:00
parent bb3d1bf7c9
commit 3619526af0
31 changed files with 242 additions and 26 deletions

View File

@ -1,3 +0,0 @@
from . import models
from . import controllers

View File

@ -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)

View File

@ -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',
}

View File

@ -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")

View File

@ -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 <db-container> psql -U odoo -d <dbname> < 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 <dbname>"';
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;

View File

@ -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);

View File

@ -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

View File

@ -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 };
}

View File

@ -1,4 +1,4 @@
<t t-name="open_workshop.OwsMachineAccessList">
<t t-name="open_workshop_base.OwsMachineAccessList">
<div class="client-details-grid p-2 small">
<!-- ✅ Sicherheitsbereich -->

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="open_workshop.OwsPosCustomerSidebar" owl="1">
<t t-name="open_workshop_base.OwsPosCustomerSidebar" owl="1">
<div class="ows-sidebar p-2 bg-light border-end h-100">
<div class="ows-sidebar-header mb-2 d-flex justify-content-between align-items-center">
<button class="btn btn-secondary" t-on-click="openTicketScreen">Orders</button>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="open_workshop.OwsPosSidebar" owl="1">
<t t-name="open_workshop_base.OwsPosSidebar" owl="1">
<div class="custompane d-flex flex-column border-end bg-200">
<OwsPosCustomerSidebar />
<OwsMachineAccessList />

View File

@ -1,8 +1,8 @@
<odoo>
<template id="assets_open_workshop" inherit_id="point_of_sale._assets_pos">
<xpath expr="." position="inside">
<script type="text/javascript" src="/open_workshop/static/src/js/machine_access_sidebar.js"/>
<link rel="stylesheet" type="text/css" href="/open_workshop/static/src/css/pos.css"/>
<script type="text/javascript" src="/open_workshop_base/static/src/js/machine_access_sidebar.js"/>
<link rel="stylesheet" type="text/css" href="/open_workshop_base/static/src/css/pos.css"/>
</xpath>
</template>
</odoo>

View File

@ -8,7 +8,7 @@
</record>
<!-- Menüpunkt unter Maschinen > Konfiguration -->
<menuitem id="menu_machine_area" name="Bereiche" parent="menu_machine_config" action="open_workshop.action_machine_area_list" sequence="30"/>
<menuitem id="menu_machine_area" name="Bereiche" parent="menu_machine_config" action="open_workshop_base.action_machine_area_list" sequence="30"/>
<!-- Listenansicht -->
<record id="view_machine_area_tree" model="ir.ui.view">

View File

@ -30,7 +30,7 @@
<menuitem id="menu_machine_list_action"
name="Alle Maschinen"
parent="menu_machine_config"
action="open_workshop.action_machine_list"
action="open_workshop_base.action_machine_list"
sequence="10"/>
<!-- Menücontainer: Zuordnungen -->