我正在撰写Aeroo报告以打印OpenERP产品标签。
我设法打印产品的名称,描述,图像,条形码...但我的价格有问题。我可以打印产品的基本价格,不含税:
<o.price>
但是我需要打印含税和税金的价格,我该如何实现呢?
编辑: 这是有效的,但必须是一个更好的方法:
<o.list_price * ( 1 + sum([t.amount for t in o.taxes_id]))>
并没有考虑折扣
感谢, LLUIS
答案 0 :(得分:1)
解决了创建模块并将pvp方法添加到使用tax.compute_all的product_product
from osv import fields, osv
class product_product(osv.osv):
_name = "product.product"
_inherit = "product.product"
def _pvp(self, cr, uid, ids, field_name, arg, context=None):
"""Return calculated PVP with taxes
"""
res = {}
tax_obj = self.pool.get('account.tax')
for product in self.browse(cr, uid, ids, context):
t = tax_obj.compute_all(cr, uid, product.taxes_id, product.list_price, 1)['total_included']
res[product.id] = "{0:.2f}".format(t)
return res
_columns = {
'pvp': fields.function(_pvp, type="string", method=True, string="PVP"), # calculates PVP with taxes
}
product_product()