本文整理汇总了Python中netforce.utils.get_data_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_data_path函数的具体用法?Python get_data_path怎么用?Python get_data_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_data_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_cost_price
def update_cost_price(self, context):
data = context["data"]
path = context["path"]
line = get_data_path(data, path, parent=True)
cost_price_cur=line["cost_price_cur"] or 0
qty=line["qty"] or 0
currency_id=data["currency_id"]
if not currency_id:
raise Exception("Missing currency")
currency=get_model("currency").browse(currency_id)
currency_rate=data["currency_rate"]
date=data["date"]
settings=get_model("settings").browse(1)
if not currency_rate:
if currency_id == settings.currency_id.id:
currency_rate = 1
else:
rate_from = currency.get_rate(date=date)
if not rate_from:
raise Exception("Missing currency rate for %s" % currency.code)
rate_to = settings.currency_id.get_rate(date=date)
if not rate_to:
raise Exception("Missing currency rate for %s" % settings.currency_id.code)
currency_rate = rate_from / rate_to
cost_price=get_model("currency").convert(cost_price_cur,currency_id,settings.currency_id.id,rate=currency_rate)
cost_amount=cost_price*qty
line["cost_price"]=cost_price
line["cost_amount"]=cost_amount
return data
示例2: onchange_product
def onchange_product(self, context):
data = context["data"]
path = context["path"]
line = get_data_path(data, path, parent=True)
prod_id = line.get("product_id")
if not prod_id:
return {}
prod = get_model("product").browse(prod_id)
line["description"] = prod.description
line["qty"] = 1
if prod.uom_id is not None:
line["uom_id"] = prod.uom_id.id
pricelist_id = data["price_list_id"]
price = None
if pricelist_id:
price = get_model("price.list").get_price(pricelist_id, prod.id, 1)
price_list = get_model("price.list").browse(pricelist_id)
price_currency_id = price_list.currency_id.id
if price is None:
price = prod.purchase_price
settings = get_model("settings").browse(1)
price_currency_id = settings.currency_id.id
if price is not None:
currency_id = data["currency_id"]
price_cur = get_model("currency").convert(price, price_currency_id, currency_id)
line["unit_price"] = price_cur
if prod.purchase_tax_id is not None:
line["tax_id"] = prod.purchase_tax_id.id
if prod.location_id:
line["location_id"] = prod.location_id.id
data = self.update_amounts(context)
return data
示例3: onchange_product
def onchange_product(self, context):
data = context["data"]
type = data["type"]
path = context["path"]
contact_id = data["contact_id"]
contact = get_model("contact").browse(contact_id)
line = get_data_path(data, path, parent=True)
prod_id = line.get("product_id")
if not prod_id:
return {}
prod = get_model("product").browse(prod_id)
line["description"] = prod.description
line["qty"] = 1
if prod.uom_id is not None:
line["uom_id"] = prod.uom_id.id
if type == "out":
if prod.sale_price is not None:
line["unit_price"] = prod.sale_price
if prod.sale_account_id is not None:
line["account_id"] = prod.sale_account_id.id
if prod.sale_tax_id is not None:
line["tax_id"] = contact.tax_receivable_id.id or prod.sale_tax_id.id
elif type == "in":
if prod.purchase_price is not None:
line["unit_price"] = prod.purchase_price
if prod.purchase_account_id is not None:
line["account_id"] = prod.purchase_account_id.id
if prod.purchase_tax_id is not None:
line["tax_id"] = contact.tax_payable_id.id or prod.purchase_tax_id.id
data = self.update_amounts(context)
return data
示例4: onchange_qty
def onchange_qty(self, context):
data = context["data"]
path = context["path"]
line = get_data_path(data, path, parent=True)
prod_id = line.get("product_id")
if not prod_id:
return {}
prod = get_model("product").browse(prod_id)
pricelist_id = data["price_list_id"]
qty = line["qty"]
if line.get("unit_price") is None:
price = None
if pricelist_id:
price = get_model("price.list").get_price(pricelist_id, prod.id, qty)
price_list = get_model("price.list").browse(pricelist_id)
price_currency_id = price_list.currency_id.id
if price is None:
price = prod.sale_price
settings = get_model("settings").browse(1)
price_currency_id = settings.currency_id.id
if price is not None:
currency_id = data["currency_id"]
price_cur = get_model("currency").convert(price, price_currency_id, currency_id)
line["unit_price"] = price_cur
data = self.update_amounts(context)
return data
示例5: onchange_book
def onchange_book(self, context={}):
data = context["data"]
path = context["path"]
line = get_data_path(data,path,parent=True)
book_id = line["book_id"]
book = get_model("bookstore.book").browse(book_id)
line["unit_price"]=book.cost
return data
示例6: get_line_desc
def get_line_desc(self, context):
data = context["data"]
path = context["path"]
if not data.get("default_line_desc"):
return
if not get_data_path(data, path):
set_data_path(data, path, data.get("narration"))
return data
示例7: onchange_product
def onchange_product(self, context={}):
data = context.get('data')
path = context.get('path')
line = get_data_path(data, path, parent=True)
product = get_model('product').browse(line['product_id'])
line['description'] = product.description if product.description else "-"
line['uom_id'] = product.uom_id.id
return data
示例8: onchange_product
def onchange_product(self,context={}):
data=context['data']
path=context['path']
line=get_data_path(data,path,parent=True)
product_id=line['product_id']
if product_id:
product=get_model('product').browse(product_id)
line['uom_id']=product.uom_id.id
return data
示例9: onchange_to_product
def onchange_to_product(self, context={}):
data = context["data"]
path = context["path"]
line = get_data_path(data, path, parent=True)
prod_id = line.get("product_id")
prod = get_model("product").browse(prod_id)
line["uom_id"] = prod.uom_id.id
line["qty"] = 1
return data
示例10: onchange_product
def onchange_product(self, context):
data = context["data"]
path = context["path"]
line = get_data_path(data, path, parent=True)
product_id = line["product_id"]
prod = get_model("product").browse(product_id)
line["description"] = prod.description
line["unit_price"] = prod.cost_price
return data
示例11: onchange_lot
def onchange_lot(self, context):
data = context["data"]
loc_id = data["location_from_id"]
path = context["path"]
line = get_data_path(data, path, parent=True)
prod_id = line["product_id"]
lot_id = line["lot_id"]
res = get_model("stock.location").compute_balance([loc_id], prod_id, lot_id=lot_id)
line["qty"] = res["bal_qty"]
return data
示例12: onchange_est_margin
def onchange_est_margin(self,context={}):
data=context["data"]
path=context["path"]
line=get_data_path(data,path,parent=True)
margin=line["est_margin_percent_input"]
amt=line["est_cost_amount"]/(1-margin/Decimal(100))
price=round(amt/line["qty"])
line["unit_price"]=price
self.update_amounts(context)
return data
示例13: onchange_product
def onchange_product(self, context):
data = context["data"]
path = context["path"]
line = get_data_path(data, path, parent=True)
prod_id = line.get("product_id")
if not prod_id:
return {}
prod = get_model("product").browse(prod_id)
line["uom_id"] = prod.uom_id.id
return data
示例14: onchange_account
def onchange_account(self, context):
data = context["data"]
path = context["path"]
line = get_data_path(data, path, parent=True)
acc_id = line.get("account_id")
if not acc_id:
return {}
acc = get_model("account.account").browse(acc_id)
line["tax_id"] = acc.tax_id.id
data = self.update_amounts(context)
return data
示例15: onchange_qc_test
def onchange_qc_test(self, context):
data = context["data"]
path = context["path"]
line = get_data_path(data, path, parent=True)
test_id = line.get("test_id")
if not test_id:
return
test = get_model("qc.test").browse(test_id)
line["min_value"] = test.min_value
line["max_value"] = test.max_value
return data