odoo。 api.onchange do die dip dip dip
我正在尝试覆盖onChange
account.move.line
模型的函数,以更新我已添加到account的自定义字段的值。移动
模型:
class SoftOneInvoiceLine(models.Model):
_inherit= "account.move.line"
change_from_user=fields.Boolean('Change by user',default=True)
@api.onchange('quantity', 'discount', 'price_unit', 'tax_ids')
def _onchange_price_subtotal(self):
super(SoftOneInvoiceLine,self)._onchange_price_subtotal()
for rec in self:
if (rec.change_from_user):
rec.move_id.global_discount=0
rec.move_id.write({'global_discount':0})
print (rec.move_id," ",rec.move_id.global_discount)
rec.change_from_user=True
上面的代码,当您更改account.move.line的4个字段之一时,不会以形式更改global_discount字段的值。
_onchange_price_subtotal
函数被执行,因为打印命令显示在日志中,
为什么global_discount不反映UI?
I'm trying to override an onchange
function of account.move.line
model in order to update the value of a custom field I've added to the account. move
model:
class SoftOneInvoiceLine(models.Model):
_inherit= "account.move.line"
change_from_user=fields.Boolean('Change by user',default=True)
@api.onchange('quantity', 'discount', 'price_unit', 'tax_ids')
def _onchange_price_subtotal(self):
super(SoftOneInvoiceLine,self)._onchange_price_subtotal()
for rec in self:
if (rec.change_from_user):
rec.move_id.global_discount=0
rec.move_id.write({'global_discount':0})
print (rec.move_id," ",rec.move_id.global_discount)
rec.change_from_user=True
The code above, doesn't change the value of the global_discount field in the form when you change one of the 4 fields of account.move.line.
The _onchange_price_subtotal
functions gets executed, because the print command is displayed in the logs
Why doesn't global_discount new value doesn't reflect on UI?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有
尝试过更新?
另外,您不反思UI的意思是什么?它在DB表中更新吗?
Instead of
have you tried update ?
Also, what you meant by not reflecting in UI ? Is it updated in db table ?