def salesreport_add(request):
    """添加"""
    if request.method == 'GET':
        form = SalesreportForm()
        return render(request, 'web/form_submit.html', context=locals())
    form = SalesreportForm(data=request.POST)
    if form.is_valid():
        form.save()
        # 更新一条数据库记录
        model = salesreport.objects
        model_id_update(request, model, get_model_last_id(model))
        return redirect('/web/materialreport/list/(.+)')
    return render(request, 'web/form_submit.html', context=locals())
Esempio n. 2
0
def receivable_add(request):
    """添加"""
    if request.method == 'GET':
        form = ReceivableForm()
        return render(request, 'web/form_submit.html', context=locals())
    form = ReceivableForm(data=request.POST)
    if form.is_valid():
        form.save()
        # 更新一条数据库记录
        model = Receivable.objects
        model_id_update(request, model, get_model_last_id(model))
        return redirect('/web/receivable/list/(.+)')
    return render(request, 'web/form_submit.html', context=locals())
Esempio n. 3
0
def warehousing_add(request):
    """添加 成品入库"""
    if request.method == 'GET':
        form = WarehousingForm()
        return render(request, 'web/form_submit.html', context=locals())
    form = WarehousingForm(data=request.POST)
    if form.is_valid():
        form.save()
        # 更新一条数据库记录
        model = Warehousing.objects
        model_id_update(request, model, get_model_last_id(model))
        return redirect('/web/warehousing/list/(.+)')
    return render(request, 'web/form_submit.html', context=locals())
def copewith_add(request):
    """添加"""
    if request.method == 'GET':
        form = CopewithForm()
        return render(request,
                      'web/copewith/copewith_add.html',
                      context=locals())
    form = CopewithForm(data=request.POST)
    if form.is_valid():
        form.save()
        # 更新一条数据库记录
        model = Copewith.objects
        copewith_id_update(request, model, get_model_last_id(model))
        return redirect('/web/copewith/list/(.+)')
    return render(request, 'web/copewith/copewith_add.html', context=locals())
def purchase_add(request):
    """添加采购"""
    if request.method == 'GET':
        name_list = set(models.Purchase.objects.values_list(
            'name', flat=True))  # 送货产品名称
        product_list = set(
            models.Purchase.objects.values_list('product', flat=True))  #采购产品名称
        return render(request,
                      'web/purchase/purchase_add.html',
                      context=locals())
    cleanData = request.POST.dict()  #POST对象直接转为字典
    dict.pop(cleanData, 'csrfmiddlewaretoken')  #删除字典中的键'csrfmiddlewaretoken'和值
    models.Purchase(**cleanData).save()
    # 更新数据库记录
    model = models.Purchase.objects
    purchase_id_update(request, model, get_model_last_id(model))
    return redirect('/web/purchase/list/(.+)')