SO销售单和PO采购单,一定要在原始主类下添加字段,不能在继承类添加字段,不然xml识别不到字段。
SO销售单:
添加express_price字段后,找到def _compute_amount(self):方法,最后两行加入小计和合计的计算逻辑:
@api.depends('product_uom_qty', 'discount', 'price_unit', 'tax_id')
def _compute_amount(self):
"""
Compute the amounts of the SO line.
"""
for line in self:
price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
taxes = line.tax_id.compute_all(price, line.order_id.currency_id, line.product_uom_qty, product=line.product_id, partner=line.order_id.partner_shipping_id)
line.update({
'price_tax': sum(t.get('amount', 0.0) for t in taxes.get('taxes', [])),
'price_total': taxes['total_included'],
'price_subtotal': taxes['total_excluded'],
})
line.price_subtotal = line.product

本文介绍了如何在Odoo12的SO和PO订单中添加运费字段。强调字段需在原始主类添加,以确保XML识别。在SO订单中,更新了_def_compute_amount_方法以计算小计和总计。而PO订单的运费取自SO订单,同样在主类添加计算逻辑,并更新小计和总计。
309

被折叠的 条评论
为什么被折叠?



