【发布时间】:2019-03-03 14:23:55
【问题描述】:
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
【问题讨论】:
-
尝试扩展
_onchange_quantity(),就像你提到的我的回答一样,并在那里设置price_unit。 -
复制的确切代码现在在链接上给出,仍然无法正常工作:(
-
好的,找到问题了,我在两个函数中都错误地缩进了return
-
最终解决方案是什么?只需将其发布为您的答案。
-
刚刚发布,感谢您指导我完成
标签: python odoo onchange odoo-11