feat(sync): Add force_espo_wins option for conflict resolution in bidirectional sync
This commit is contained in:
@@ -158,19 +158,20 @@ async def handler(event_data, context):
|
||||
context.logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
async def run_kommunikation_sync(entity_id: str, betnr: int, komm_sync, context, direction: str = 'both') -> Dict[str, Any]:
|
||||
async def run_kommunikation_sync(entity_id: str, betnr: int, komm_sync, context, direction: str = 'both', force_espo_wins: bool = False) -> Dict[str, Any]:
|
||||
"""
|
||||
Helper: Führt Kommunikation-Sync aus mit Error-Handling
|
||||
|
||||
Args:
|
||||
direction: 'both' (bidirektional), 'to_advoware' (nur EspoCRM→Advoware), 'to_espocrm' (nur Advoware→EspoCRM)
|
||||
force_espo_wins: Erzwingt EspoCRM-wins Konfliktlösung (für Stammdaten-Konflikte)
|
||||
|
||||
Returns:
|
||||
Sync-Ergebnis oder None bei Fehler
|
||||
"""
|
||||
context.logger.info(f"📞 Starte Kommunikation-Sync (direction={direction})...")
|
||||
try:
|
||||
komm_result = await komm_sync.sync_bidirectional(entity_id, betnr, direction=direction)
|
||||
komm_result = await komm_sync.sync_bidirectional(entity_id, betnr, direction=direction, force_espo_wins=force_espo_wins)
|
||||
context.logger.info(f"✅ Kommunikation synced: {komm_result}")
|
||||
return komm_result
|
||||
except Exception as e:
|
||||
@@ -419,7 +420,7 @@ async def handle_update(entity_id, betnr, espo_entity, espocrm, advoware, sync_u
|
||||
)
|
||||
|
||||
# KOMMUNIKATION SYNC: NUR EspoCRM→Advoware (EspoCRM wins!)
|
||||
await run_kommunikation_sync(entity_id, betnr, komm_sync, context, direction='to_advoware')
|
||||
await run_kommunikation_sync(entity_id, betnr, komm_sync, context, direction='to_advoware', force_espo_wins=True)
|
||||
|
||||
# Release Lock NACH Kommunikation-Sync
|
||||
await sync_utils.release_sync_lock(entity_id, 'clean')
|
||||
|
||||
Reference in New Issue
Block a user