예제 #1
0
파일: factories.py 프로젝트: krisera/shoop
def create_product(sku, shop=None, supplier=None, default_price=None):
    if default_price is not None:
        default_price = shop.create_price(default_price)

    product = Product(type=get_default_product_type(),
                      tax_class=get_default_tax_class(),
                      sku=sku,
                      name=sku.title(),
                      width=100,
                      height=100,
                      depth=100,
                      net_weight=100,
                      gross_weight=100,
                      sales_unit=get_default_sales_unit(),
                      stock_behavior=StockBehavior.UNSTOCKED)
    product.full_clean()
    product.save()
    if shop:
        sp = ShopProduct.objects.create(product=product,
                                        shop=shop,
                                        default_price=default_price)
        if supplier:
            sp.suppliers.add(supplier)
        sp.save()

    return product
예제 #2
0
def create_product(sku, shop=None, supplier=None, default_price=None):
    if default_price is not None:
        default_price = shop.create_price(default_price)

    product = Product(
        type=get_default_product_type(),
        tax_class=get_default_tax_class(),
        sku=sku,
        name=sku.title(),
        width=100,
        height=100,
        depth=100,
        net_weight=100,
        gross_weight=100,
        sales_unit=get_default_sales_unit(),
        stock_behavior=StockBehavior.UNSTOCKED
    )
    product.full_clean()
    product.save()
    if shop:
        sp = ShopProduct.objects.create(product=product, shop=shop, default_price=default_price)
        if supplier:
            sp.suppliers.add(supplier)
        sp.save()

    return product