odoo12 SO PO 订单行加入运费字段,计算小计和总计

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

        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'],
               
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值