def basequeryset(request, *args, **kwargs): current, start, end = getHorizon(request) return DistributionOrder.objects.all() \ .filter(startdate__lte=end, enddate__gte=start) \ .annotate(key=RawSQL("coalesce(item_id,'') || coalesce(origin_id,'') || coalesce(destination_id,'')", ())) \ .distinct('key') \ .order_by() # Ordering isn't compatible with the distinct
def basequeryset(request, *args, **kwargs): current, start, end = getHorizon(request) return (PurchaseOrder.objects.all( ).filter(startdate__lte=end, enddate__gte=start).annotate(key=RawSQL( "coalesce(item_id,'') || coalesce(location_id,'') || coalesce(supplier_id,'')", (), )).distinct("key").order_by() ) # Ordering isn't compatible with the distinct
def basequeryset(request, args, kwargs): if args and args[0]: request.session['lasttab'] = 'plan' return Operation.objects.all() else: current, start, end = getHorizon(request) return Operation.objects.all().extra( where=['exists (select 1 from operationplan where operationplan.operation_id = operation.name and startdate <= %s and enddate >= %s)'], params=[end, start] )
def basequeryset(request, *args, **kwargs): if args and args[0]: request.session['lasttab'] = 'plan' return Operation.objects.all() else: current, start, end = getHorizon(request) return Operation.objects.all().extra( where=['exists (select 1 from operationplan where operationplan.operation_id = operation.name and startdate <= %s and enddate >= %s)'], params=[end, start] )
def basequeryset(request, *args, **kwargs): if args and args[0]: request.session["lasttab"] = "plan" return Operation.objects.filter(name=args[0]) else: current, start, end = getHorizon(request) return Operation.objects.all().extra( where=[ "exists (select 1 from operationplan where operationplan.operation_id = operation.name and startdate <= %s and enddate >= %s)" ], params=[end, start], )
def basequeryset(request, *args, **kwargs): current, start, end = getHorizon(request) return DistributionOrder.objects.all() \ .filter(startdate__lte=end, enddate__gte=start) \ .distinct('item', 'origin', 'destination') \ .order_by() # Ordering isn't compatible with the distinct
def basequeryset(request, *args, **kwargs): current, start, end = getHorizon(request) return PurchaseOrder.objects.all() \ .filter(startdate__lte=end, enddate__gte=start) \ .distinct('item', 'supplier', 'location') \ .order_by() # Ordering isn't compatible with the distinct