大佬教程收集整理的这篇文章主要介绍了使用 Onchange 更新 one2many 字段。奥多14,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
由于未保存字段“tax_IDs_after_fiscal_position”的问题,我尝试使用在 pos.order.line 模型中调用的以下函数更新 One2many 字段 这是我的代码:
class PosOrderline(models.Model):
_inherit = "pos.order.line"
@API.onchange('product_ID')
def _onchange_product_ID(self):
self.tax_IDs_after_fiscal_position = self.product_ID.taxes_ID
self.write({'tax_IDs_after_fiscal_position': [(4,self.product_ID.taxes_ID)]})
我收到以下错误:
The above exception was the direct cause of the following exception:
TraceBACk (most recent call last):
file "/usr/lib/python3/dist-packages/odoo/http.py",line 639,in _handle_exception
return super(Jsonrequest,self)._handle_exception(exception)
file "/usr/lib/python3/dist-packages/odoo/http.py",line 315,in _handle_exception
raise exception.with_traceBACk(NonE) from new_cause
AttributeError: 'account.tax' object has no attribute 'ref'
请问怎么了? 有什么帮助吗? 谢谢。
请不要在 onchange 内使用 write。
@api.onchange('product_id')
def _onchange_product_id(self):
self.tax_ids_after_fiscal_position = [(6,self.product_id.taxes_id.ids)]
以上是大佬教程为你收集整理的使用 Onchange 更新 one2many 字段。奥多14全部内容,希望文章能够帮你解决使用 Onchange 更新 one2many 字段。奥多14所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。