docs(migration): Add comments explaining related field synchronization

Added documentation to clarify:
- Why store=True is used for related fields (performance for filtering/searching)
- Why manual synchronization is needed in migration (related fields don't auto-sync during SQL INSERT)

No functional changes, only improved code documentation.
This commit is contained in:
Matthias Lotz 2025-12-15 20:46:14 +01:00
parent bd235e3ca0
commit 686b201792
2 changed files with 3 additions and 1 deletions

View File

@ -99,7 +99,8 @@ def migrate(cr, version):
except Exception as e:
_logger.error(f"Failed to migrate machine {m_id}: {e}")
# 3. Synchronisiere related fields von ows.machine nach maintenance.equipment
# 3. Synchronisiere related fields von ows.machine → maintenance.equipment
# Nötig weil related fields mit store=True nicht automatisch bei SQL-INSERT synchronisiert werden
_logger.info("Synchronizing related fields (area_id, category) to maintenance.equipment...")
cr.execute("""

View File

@ -414,6 +414,7 @@ class MaintenanceEquipment(models.Model):
ows_machine_id = fields.One2many('ows.machine', 'equipment_id', string='OWS Maschine', readonly=True)
# OWS-Felder direkt auf Equipment (via related für einfache Bearbeitung)
# store=True für Performance beim Filtern/Suchen
ows_category = fields.Selection(
related='ows_machine_id.category',
string='Sicherheitskategorie',