繁体   English   中英

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

[英]odoo 11 @api.onchange() not working on price_unit field in purchase.order.line

odoo 11 onchange不适用于purchase.order.line中的price_unit,而适用于折扣字段。

以下是我从Odoo onchange复制的代码无法正常工作 ,然后进行了修改:

@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

有效的解决方案:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM