Пример #1
0
def create(request, sn=None, product_id=None, note_id=None):

    profile = request.user.get_profile()
    order = Order.objects.create(created_by=request.user)

    if sn:
        try:
            device = Device.objects.get(sn=sn)
        except Device.DoesNotExist:
            GsxAccount.default()
            device = Device.from_gsx(sn)
            
        order.devices.add(device)
        order.save()

    # creating an order from a product
    if product_id:
        product = Product.objects.get(pk=product_id)
        order.add_product(product)

    if note_id:
        note = Note.objects.get(pk=note_id)
        note.order = order
        note.save()
        # try to match a customer
        if note.sender:
            try:
                customer = Customer.objects.get(email=note.sender)
                order.customer = customer
                order.save()
            except Customer.DoesNotExist:
                pass

    return redirect(order)
Пример #2
0
def index_outgoing(request, shipment=None, date=None):
    if request.is_ajax():
        return HttpResponse('5')

    GsxAccount.default()

    if request.method == 'POST':
        pass

    parts = gsx.Returns(shipToCode='677592').get_pending()

    return render(request, 'products/index_outgoing.html', {'parts': parts})
Пример #3
0
def order_stock(request, po_id):
    po = PurchaseOrder.objects.get(pk=po_id)
    GsxAccount.default()
    items = []

    profile = request.user.get_profile()
    ship_to = profile.location.ship_to

    stock_order = gsx.Order(shipToCode=ship_to, purchaseOrderNumber=po.id)

    for i in po.purchaseorderitem_set.all():
        stock_order.add_part(i.code, i.amount)

    result = stock_order.submit()
    po.confirmation = result.confirmationNumber
    po.date_submitted = datetime.now()
    po.save()

    messages.add_message(request, messages.INFO, _(u'Tuotteet tilattu viittellä %s' % po.confirmation))
    return redirect('/products/po/')
Пример #4
0
def view(request, product_id=None, code=None):

    product = Product()
    try:
        product = Product.objects.get(pk=product_id)
    except Product.DoesNotExist:
        gsx = GsxAccount.default()
        product = gsx.parts_lookup({'partNumber': code})[0]
        product = ServicePart(product)
    
    return render(request, 'products/view.html', {'product': product})
Пример #5
0
def parts(request, order_id, device_id):
    # List available parts for this device/order
    # taking into account the order's queues GSX account...
    order = Order.objects.get(pk=order_id)
    device = Device.objects.get(pk=device_id)

    try:
        act = order.queue.gsx_account
        gsx = act.connect()
    except Exception, e:
        print "Using default GSX account..."
        gsx = GsxAccount.default()
Пример #6
0
def add_device(request, order_id, device_id=None, sn=None):
    order = Order.objects.get(pk=order_id)

    if device_id:
        device = Device.objects.get(pk=device_id)
    
    if sn:
        act = GsxAccount.default()
        device = Device.from_gsx(sn)
    
    order.devices.add(device)
    order.save()

    messages.add_message(request, messages.INFO,
        _(u'%s lisätty' % device.description))
    return redirect(order)
Пример #7
0
def edit(request, product_id=0, code=None):
    
    if request.method == 'POST':
        return save(request, product_id)

    result = {}
    form = ProductForm()

    if int(product_id) > 0:
        product = Product.objects.get(pk=product_id)
        form = ProductForm(instance=product)
        product_id = product.id
    
    if code:
        # We shoose the GSX account here since orders in different queues
        # might use a different accounts...
        act = GsxAccount.default()
        product = Product.from_gsx(code, act)
        form = ProductForm(instance=product)
    
    return render(request, 'products/form.html', {
        'form': form
        })
Пример #8
0
def return_label(request, return_order, part_number):
    GsxAccount.default()
    label = gsx.Returns(return_order).get_label(part_number)
    return HttpResponse(label.returnLabelFileData, content_type='application/pdf')
Пример #9
0
                price=soi.price,
                purchase_order=po,
                product=soi.product,
                date_ordered=datetime.now())

        repair['poNumber'] = str(po.id)
        del(repair['device'])

        try:
            act = order.queue.gsx_account
            act.connect()
            repair['shipTo'] = act.ship_to
        except Exception, e:
            print e
            repair['shipTo'] = profile.location.ship_to
            GsxAccount.default()
        
        try:
            print repair
            rep = gsx.Repair(**repair)
            result = rep.create_carryin()
            confirmation = result.confirmationNumber
            po.confirmation = confirmation
            po.date_submitted = datetime.now()
            po.save()
            description =  _(u'GSX huolto %s luotu' % confirmation)
            order.notify('gsx_repair_created', description, request.user)
            messages.add_message(request, messages.INFO, description)
            return redirect(order)
        except Exception, e:
            messages.add_message(request, messages.ERROR, e)