本文整理汇总了Python中product.Product.update方法的典型用法代码示例。如果您正苦于以下问题:Python Product.update方法的具体用法?Python Product.update怎么用?Python Product.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类product.Product
的用法示例。
在下文中一共展示了Product.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import update [as 别名]
def write(user_id, password, model, odoo_id, vals):
_check_user(user_id, password)
if model not in ["customer", "product"]:
raise Fault("unknown_model", "Reference model does not exist!")
if model == "customer":
try:
customer = Customer.get(Customer.odoo_id == odoo_id)
except Customer.DoesNotExist:
raise Fault("unknown_registry", "Customer not found!")
q = Customer.update(**vals).where(Customer.odoo_id == odoo_id)
else:
try:
product = Product.get(Product.odoo_id == odoo_id)
except Product.DoesNotExist:
raise Fault("unknown_registry", "Product not found!")
q = Product.update(**vals).where(Product.odoo_id == odoo_id)
q.execute()
return True
示例2: create
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import update [as 别名]
def create(user_id, password, model, vals):
_check_user(user_id, password)
odoo_id = vals["odoo_id"]
if model not in ["customer", "product"]:
raise Fault("unknown_model", "Reference model does not exist!")
if model == "customer":
try:
customer = Customer.get(Customer.odoo_id == odoo_id)
except Customer.DoesNotExist:
q = Customer.insert(**vals)
else:
q = Customer.update(**vals).where(Customer.odoo_id == odoo_id)
else:
try:
product = Product.get(Product.odoo_id == odoo_id)
except Product.DoesNotExist:
q = Product.insert(**vals)
else:
q = Product.update(**vals).where(Product.odoo_id == odoo_id)
q.execute()
return True