diese Version lässt sich mit einer integrierten mirgration auf eine bestehende DB installieren, es fehlen noch die Einweisungen
This commit is contained in:
parent
e14531fa7f
commit
0454aebc95
|
|
@ -1,2 +1,5 @@
|
||||||
from . import models
|
from . import models
|
||||||
from . import controllers # <- hinzufügen
|
from . import controllers
|
||||||
|
from . import post_init_hook
|
||||||
|
# damit run_migration sichtbar ist:
|
||||||
|
run_migration = post_init_hook.run_migration
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
'category': 'Point of Sale',
|
'category': 'Point of Sale',
|
||||||
'data': [
|
'data': [
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
|
'views/machine_product_training_views.xml',
|
||||||
'views/menu_views.xml',
|
'views/menu_views.xml',
|
||||||
'views/machine_area_views.xml',
|
'views/machine_area_views.xml',
|
||||||
'views/machine_views.xml',
|
'views/machine_views.xml',
|
||||||
|
|
@ -18,7 +19,6 @@
|
||||||
'data/data_product_and_categories.xml',
|
'data/data_product_and_categories.xml',
|
||||||
'data/machine_product_links.xml',
|
'data/machine_product_links.xml',
|
||||||
|
|
||||||
|
|
||||||
],
|
],
|
||||||
'qweb': [
|
'qweb': [
|
||||||
'static/src/xml/ows_briefing_details.xml',
|
'static/src/xml/ows_briefing_details.xml',
|
||||||
|
|
@ -33,5 +33,5 @@
|
||||||
#'static/src/js/debug.js',
|
#'static/src/js/debug.js',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
'post_init_hook': 'run_migration',
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# export_categories.py
|
# /opt/odoo/odoo/odoo-bin shell -d <alte datebase> < export_categories.py
|
||||||
import csv
|
import csv
|
||||||
from odoo import api, SUPERUSER_ID
|
from odoo import api, SUPERUSER_ID
|
||||||
import os
|
import os
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# export_products.py
|
# /opt/odoo/odoo/odoo-bin shell -d <alte datebase> < export_products.py
|
||||||
import csv
|
import csv
|
||||||
from odoo import api, SUPERUSER_ID
|
from odoo import api, SUPERUSER_ID
|
||||||
import os
|
import os
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# /opt/odoo/odoo/odoo-bin shell -d <alte datebase> < export_products_and_categories.py
|
||||||
|
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
def xml_safe_id(name):
|
def xml_safe_id(name):
|
||||||
|
|
|
||||||
40
data/fix_missing_pos_partner.py
Normal file
40
data/fix_missing_pos_partner.py
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
from odoo import SUPERUSER_ID
|
||||||
|
|
||||||
|
def fix_missing_pos_order_partners(cr, registry):
|
||||||
|
"""
|
||||||
|
Findet POS-Bestellungen mit fehlendem Partner und fügt Dummy-Partner
|
||||||
|
direkt per SQL mit der passenden ID ein.
|
||||||
|
"""
|
||||||
|
cr.execute("""
|
||||||
|
SELECT DISTINCT partner_id FROM pos_order
|
||||||
|
WHERE partner_id IS NOT NULL
|
||||||
|
AND partner_id NOT IN (SELECT id FROM res_partner)
|
||||||
|
""")
|
||||||
|
missing_ids = [row[0] for row in cr.fetchall()]
|
||||||
|
print(f"Superuser: {SUPERUSER_ID}")
|
||||||
|
if not missing_ids:
|
||||||
|
print("✅ Keine fehlenden Partner gefunden.")
|
||||||
|
return
|
||||||
|
|
||||||
|
print(f"🚧 Fehlende Partner-IDs: {missing_ids}")
|
||||||
|
|
||||||
|
# Direkter SQL-Insert für res_partner
|
||||||
|
for pid in missing_ids:
|
||||||
|
print(f"➕ Erzeuge Dummy-Partner mit ID {pid}")
|
||||||
|
cr.execute("""
|
||||||
|
INSERT INTO res_partner (id, name, customer_rank, create_uid, create_date, write_uid, write_date)
|
||||||
|
VALUES (%s, %s, %s, %s, now(), %s, now())
|
||||||
|
ON CONFLICT (id) DO NOTHING
|
||||||
|
""", (pid, f"Fehlender Partner {pid}", 1, SUPERUSER_ID, SUPERUSER_ID))
|
||||||
|
|
||||||
|
# Sequenz zurücksetzen, um ID-Kollision zu verhindern
|
||||||
|
cr.execute("""
|
||||||
|
SELECT setval('res_partner_id_seq', (SELECT MAX(id) FROM res_partner))
|
||||||
|
""")
|
||||||
|
print("✅ Alle fehlenden Partner ergänzt.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Automatischer Start in odoo-bin shell
|
||||||
|
if 'env' in globals():
|
||||||
|
fix_missing_pos_order_partners(env.cr, env.registry)
|
||||||
20
post_init_hook.py
Normal file
20
post_init_hook.py
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- 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 Migration: {e}")
|
||||||
Loading…
Reference in New Issue
Block a user