本文整理汇总了Python中models.Product.stock方法的典型用法代码示例。如果您正苦于以下问题:Python Product.stock方法的具体用法?Python Product.stock怎么用?Python Product.stock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Product
的用法示例。
在下文中一共展示了Product.stock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_product
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import stock [as 别名]
def import_product(self, category_name, subcategory_name, code, provider_code, description, sell_price, stock,
list_cost, net_cost ):
product = None
if(description != None and description != ""):
category = self.get_category(category_name)
subcategory = self.get_subcategory(category_name, subcategory_name)
if net_cost is None:
net_cost = list_cost
try:
product = Product.objects.get(description=description )
except Product.DoesNotExist:
product = Product(code=code, provider_code = provider_code, description=description,category=category,
subcategory=subcategory)
try:
product.current_cost = Decimal(net_cost)
except:
pass
try:
product.current_sell_price = Decimal(sell_price)
except:
pass
try:
product.stock = int(stock)
except:
pass
if product != None:
product.save()
return product