首页 > 解决方案 > 在 odoo11 中更新多个字段

问题描述

我一直在尝试更新具有相同值的多个字段,但我似乎无法找到一种方法来做到这一点。 <field name="credit_limit" readonly="1" attrs="{'invisible':[('check_credit','!=',True)]}"/>

我想更新同一个数据库 res_partner 上的 custom_credit 有什么简单的方法可以通过 xml 来实现。我的最佳解决方案是隐藏字段,该字段将从上述字段中获取值,并在单击提交按钮时更新数据库。

新字段将是这样的,但它应该从credit_limit上面获取值。 <field name="custom_credit" readonly="1" type="hidden"/>

标签: xmlodoo-11qweb

解决方案


有一种简单的方法可以在 odoo 表单中更新readonly="1"invisible="1"字段,您必须添加属性force_save="1"才能这样做。但是要跟踪check_credit字段的变化,您必须编写一个@api.onchage('check_credit')函数并使用该值来设置custom_credit字段。其他方式可以是继承createwrite函数,computecustom_credit字段上使用属性,或使用related属性。


推荐阅读