Ejemplo n.º 1
0
    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')
Ejemplo n.º 2
0
    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')
Ejemplo n.º 3
0
def run():
    if SystemSettings.get_sync_start_date():
        sync()
Ejemplo n.º 4
0
def run():
    if SystemSettings.get_sync_start_date():
        sync()