当前位置: 首页>>代码示例>>Python>>正文


Python Item.company方法代码示例

本文整理汇总了Python中models.Item.company方法的典型用法代码示例。如果您正苦于以下问题:Python Item.company方法的具体用法?Python Item.company怎么用?Python Item.company使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Item的用法示例。


在下文中一共展示了Item.company方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_item

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import company [as 别名]
def create_item(request):
    """
    @param request:
    @param id:
    @return: JSON for account for added Inventory Item
    """
    item = Item(purchase_account=Account.objects.get(name='Purchase', company=request.company),
                sales_account=Account.objects.get(name='Sales', company=request.company),
                purchase_tax_scheme=TaxScheme.objects.get(name='No Tax', company=request.company),
                sales_tax_scheme=TaxScheme.objects.get(name='No Tax', company=request.company))
    scenario = 'Create'
    for query in request.GET:
        setattr(item, query, request.GET[query])
    if request.POST:
        form = ItemForm(data=request.POST, instance=item, company=request.company)
        if form.is_valid():
            item = form.save(commit=False)
            item.company = request.company
            item.save()
            if request.is_ajax():
                return render(request, 'callback.html', {'obj': InventoryAccountSerializer(item.account).data})
            return redirect('/inventory/items/')
    else:
        form = ItemForm(instance=item, company=request.company)
        form.hide_field(request)
    if request.is_ajax():
        base_template = 'modal.html'
    else:
        base_template = 'dashboard.html'
    return render(request, 'item_form.html', {
        'scenario': scenario,
        'form': form,
        'base_template': base_template,
    })
开发者ID:xtranophilist,项目名称:awecounting,代码行数:36,代码来源:views.py

示例2: item_form

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import company [as 别名]
def item_form(request, id=None):
    if id:
        item = get_object_or_404(Item, id=id, company=request.company)
        scenario = 'Update'
    else:
        item = Item(purchase_account=Account.objects.get(name='Purchase', company=request.company),
                    sales_account=Account.objects.get(name='Sales', company=request.company),
                    purchase_tax_scheme=TaxScheme.objects.get(name='No Tax', company=request.company),
                    sales_tax_scheme=TaxScheme.objects.get(name='No Tax', company=request.company))
        scenario = 'Create'
    if request.POST:
        form = ItemForm(data=request.POST, instance=item, company=request.company)
        if form.is_valid():
            item = form.save(commit=False)
            item.company = request.company
            item.save()
            if request.is_ajax():
                return render(request, 'callback.html', {'obj': ItemSerializer(item).data})
            return redirect('/inventory/items/')
    else:
        form = ItemForm(instance=item, company=request.company)
    if request.is_ajax():
        base_template = 'modal.html'
    else:
        base_template = 'dashboard.html'
    return render(request, 'item_form.html', {
        'scenario': scenario,
        'form': form,
        'base_template': base_template,
    })
开发者ID:xtranophilist,项目名称:awecounting,代码行数:32,代码来源:views.py


注:本文中的models.Item.company方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。