Python odoo 11@api.onchange()不处理purchase.order.line中的price\u unit字段
odoo 11 onchange在purchase.order.line中不处理价格单位,而在折扣字段中处理 下面是我从中复制并修改的代码:Python odoo 11@api.onchange()不处理purchase.order.line中的price\u unit字段,python,odoo,onchange,odoo-11,Python,Odoo,Onchange,Odoo 11,odoo 11 onchange在purchase.order.line中不处理价格单位,而在折扣字段中处理 下面是我从中复制并修改的代码: @api.onchange('product_id') def onchange_product_id(self): res = super(PurchaseOrderLine, self).onchange_product_id() # your logic here for rec in self: rec.pr
@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
尝试扩展
\u onchange\u quantity()
,如我的回答中所述,并在那里设置价格单位
。复制了链接上现在给出的精确代码,仍然不起作用:(好的,发现了问题,我在两个函数中都错误地缩进了return。最终的解决方案是什么?只需将其作为您的答案发布即可。刚刚发布,谢谢您指导我