feat(sync): Enhance metadata synchronization for unchanged files in Advoware sync process
This commit is contained in:
@@ -312,25 +312,27 @@ class AdvowareDocumentSyncUtils:
|
||||
"""
|
||||
updates = {}
|
||||
|
||||
# Map History fields to correct EspoCRM field names
|
||||
# Map History metadata fields to EspoCRM field names
|
||||
history_text = advo_history.get('text', '')
|
||||
history_art = advo_history.get('art', '')
|
||||
history_hnr = advo_history.get('hNr')
|
||||
|
||||
|
||||
espo_bemerkung = espo_doc.get('advowareBemerkung', '')
|
||||
espo_art = espo_doc.get('advowareArt', '')
|
||||
espo_hnr = espo_doc.get('hnr')
|
||||
|
||||
|
||||
# Check if different - sync metadata independently of file changes
|
||||
if history_text != espo_bemerkung:
|
||||
updates['advowareBemerkung'] = history_text
|
||||
|
||||
|
||||
if history_art != espo_art:
|
||||
updates['advowareArt'] = history_art
|
||||
|
||||
if history_hnr is not None and history_hnr != espo_hnr:
|
||||
updates['hnr'] = history_hnr
|
||||
|
||||
|
||||
# Sync dat (creation date from Advoware History) → advowareErstellungTimestamp
|
||||
history_dat_raw = advo_history.get('dat') or ''
|
||||
history_erstellung = history_dat_raw.replace('T', ' ')[:19] if history_dat_raw else ''
|
||||
espo_erstellung = espo_doc.get('advowareErstellungTimestamp') or ''
|
||||
if history_erstellung and history_erstellung != espo_erstellung:
|
||||
updates['advowareErstellungTimestamp'] = history_erstellung
|
||||
|
||||
# Always update lastSyncTimestamp when metadata changes (EspoCRM format)
|
||||
if len(updates) > 0:
|
||||
updates['lastSyncTimestamp'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
Reference in New Issue
Block a user