odoo 11 @ api.onchange()不在purchase.order.line的price_unit字段上工作

问题描述 投票:2回答:1

odoo 11 onchange不在purchase.order.line上的price_unit上工作,而它正在处理折扣字段。

下面是我从Odoo onchange not working correctly复制然后修改的代码:

@api.onchange('product_id')
def onchange_product_id(self):
    res = super(PurchaseOrderLine, self).onchange_product_id()
    # your logic here
    for rec in self:
        rec.price_unit = rec.product_id.list_price  

        return res

@api.onchange('price_unit')
def _onchange_price_unit(self):
    res = super(PurchaseOrderLine, self)._onchange_price_unit()
    # your logic here
    for rec in self:
        rec.discount = rec.product_id.puchase_price_discount
        return res
python odoo onchange odoo-11
1个回答
0
投票

有效的解决方案:

class PurchaseOrderLine(models.Model):
    _inherit = 'purchase.order.line'
    _description = "Purchase Order Line"


    @api.onchange('product_id')
    def onchange_product_id(self):

        res = super(PurchaseOrderLine,self).onchange_product_id()

        for rec in self:
            self.price_unit = 10

        return res
© www.soinside.com 2019 - 2024. All rights reserved.