DokuWiki: Fix partner_ref sync und Template-Cache

- partner_ref zu sync_fields hinzugefügt für automatische Synchronisation
- action_clear_template_cache() Methode hinzugefügt zum manuellen Leeren des Caches
- Template-Cache-Leeren Button im Wiki-Sync Wizard
- Debug-Logging für partner_ref Wert

Fixes: partner_ref wurde nicht automatisch synchronisiert und Template-Änderungen erforderten Server-Neustart
This commit is contained in:
Matthias Lotz 2026-01-07 12:37:34 +01:00
parent 40a5fe8b0f
commit 09f28c8070
3 changed files with 45 additions and 1 deletions

View File

@ -284,6 +284,10 @@ class MaintenanceEquipment(models.Model):
# Werte-Dictionary vorbereiten
values = self._prepare_template_values(view_type)
# Debug-Logging für partner_ref
if 'partner_ref' in values:
_logger.info(f"partner_ref Wert für {self.name}: '{values['partner_ref']}'")
# Platzhalter ersetzen
rendered_content = template_content
for key, value in values.items():
@ -605,7 +609,7 @@ class MaintenanceEquipment(models.Model):
# Felder die eine Synchronisation auslösen
sync_fields = {'name', 'serial_no', 'ows_area_id', 'category_id', 'status_id',
'model', 'partner_id', 'location', 'note', 'image_1920', 'tag_ids'}
'model', 'partner_id', 'partner_ref', 'location', 'note', 'image_1920', 'tag_ids'}
# Flag ob Übersichtstabelle aktualisiert werden soll
should_update_overview = False
@ -777,6 +781,34 @@ Diese Seite wird automatisch aktualisiert.
'overview_url': '',
}
@api.model
def action_clear_template_cache(self):
"""
Leert den Template-Cache und erzwingt ein Neuladen aller Templates aus DokuWiki.
Nützlich nach Template-Änderungen im Wiki.
Returns:
dict: Notification mit Anzahl geleerte Cache-Einträge
"""
global _template_cache
count = len(_template_cache)
cache_keys = list(_template_cache.keys())
_template_cache.clear()
_logger.info(f"Template-Cache geleert: {count} Einträge ({', '.join(cache_keys)})")
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _('Template-Cache geleert'),
'message': _(f'{count} Template(s) aus dem Cache entfernt. Nächster Sync lädt Templates neu.'),
'type': 'success',
'sticky': False,
}
}
@api.model
def action_reset_wiki_sync_status(self):
"""

View File

@ -167,3 +167,9 @@ class EquipmentWikiSyncWizard(models.TransientModel):
'target': 'new',
'context': {'show_result': True},
}
def action_clear_template_cache(self):
"""
Leert den Template-Cache (delegiert an maintenance.equipment).
"""
return self.env['maintenance.equipment'].action_clear_template_cache()

View File

@ -35,6 +35,12 @@
type="object"
class="btn-primary"
invisible="context.get('show_result', False)"/>
<button string="Template-Cache leeren"
name="action_clear_template_cache"
type="object"
class="btn-warning"
invisible="context.get('show_result', False)"
help="Leert den Template-Cache und erzwingt Neuladen beim nächsten Sync"/>
<button string="Schließen"
special="cancel"
class="btn-secondary"/>