本文整理汇总了Python中trytond.pool.Pool.compute_price方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.compute_price方法的具体用法?Python Pool.compute_price怎么用?Python Pool.compute_price使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trytond.pool.Pool
的用法示例。
在下文中一共展示了Pool.compute_price方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_price_uom
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import compute_price [as 别名]
def get_price_uom(products, name):
Uom = Pool().get('product.uom')
res = {}
field = name[:-4]
if Transaction().context.get('uom'):
to_uom = Uom(Transaction().context['uom'])
for product in products:
res[product.id] = Uom.compute_price(
product.default_uom, getattr(product, field), to_uom)
else:
for product in products:
res[product.id] = getattr(product, field)
return res
示例2: get_price_uom
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import compute_price [as 别名]
def get_price_uom(self, ids, name):
product_uom_obj = Pool().get('product.uom')
res = {}
field = name[:-4]
if Transaction().context.get('uom'):
to_uom = product_uom_obj.browse(
Transaction().context['uom'])
for product in self.browse(ids):
res[product.id] = product_uom_obj.compute_price(
product.default_uom, product[field], to_uom)
else:
for product in self.browse(ids):
res[product.id] = product[field]
return res
示例3: get_price_uom
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import compute_price [as 别名]
def get_price_uom(products, name):
Uom = Pool().get('product.uom')
res = {}
field = name[:-4]
if Transaction().context.get('uom'):
to_uom = Uom(Transaction().context['uom'])
else:
to_uom = None
for product in products:
price = getattr(product, field)
if to_uom and product.default_uom.category == to_uom.category:
res[product.id] = Uom.compute_price(
product.default_uom, price, to_uom)
else:
res[product.id] = price
return res
示例4: _update_fifo_out_product_cost_price
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import compute_price [as 别名]
def _update_fifo_out_product_cost_price(self):
"""
Update the product cost price of the given product on the move. Update
fifo_quantity on the concerned incomming moves. Return the
cost price for outputing the given product and quantity.
"""
Uom = Pool().get("product.uom")
total_qty = Uom.compute_qty(self.uom, self.quantity, self.product.default_uom, round=False)
fifo_moves = self.product.template.get_fifo_move(total_qty)
cost_price = Decimal("0.0")
consumed_qty = 0.0
for move, move_qty in fifo_moves:
consumed_qty += move_qty
move_unit_price = Uom.compute_price(move.uom, move.unit_price, move.product.default_uom)
cost_price += move_unit_price * Decimal(str(move_qty))
move.quantity = move_qty
move._update_product_cost_price("out")
move_qty = Uom.compute_qty(self.product.default_uom, move_qty, move.uom, round=False)
# Use write as move instance quantity was modified to call
# _update_product_cost_price
self.write([self.__class__(move.id)], {"fifo_quantity": (move.fifo_quantity or 0.0) + move_qty})
if Decimal(str(consumed_qty)) != Decimal("0"):
cost_price = cost_price / Decimal(str(consumed_qty))
if cost_price != Decimal("0"):
digits = self.__class__.cost_price.digits
return cost_price.quantize(Decimal(str(10.0 ** -digits[1])))
else:
return self.product.cost_price