def get_sync_start_date(key): if not VisionSyncInfo.objects.count(): return '' last_so_sync = VisionSyncInfo._get_last_successful_sync('SO') last_so_sync_str = last_so_sync.sync_date.strftime('%d%m%Y') if last_so_sync \ else SystemSettings.get_sync_start_date() if not last_so_sync or key == 'SO': return last_so_sync_str last_po_sync = VisionSyncInfo._get_last_successful_sync('PO') if key == 'PO': if not last_po_sync: return last_so_sync_str return min(last_po_sync.sync_date, last_so_sync.sync_date).strftime('%d%m%Y') last_ro_sync = VisionSyncInfo._get_last_successful_sync('RO') if key == 'RO': if not last_ro_sync: if not last_po_sync: return SystemSettings.get_sync_start_date() return min(last_po_sync.sync_date, last_so_sync.sync_date).strftime('%d%m%Y') return min(last_ro_sync.sync_date, last_po_sync.sync_date, last_so_sync.sync_date).strftime('%d%m%Y')
def run(): if SystemSettings.get_sync_start_date(): sync()