我有一个字段" required" = True,我希望以继承的形式更改为False。
<field name="customer_id" position="replace">
<attribute name="required">False</attribute>
</field>
但我得到了:
Integrity Error
The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a record while other records still reference it
- creation/update: a mandatory field is not correctly set
[object with reference: customer_id - customer.id]
答案 0 :(得分:1)
在ODOO中,如果字段设置为required = python文件中的True,则为 无法将其标记为必需= xml文件中的Flase。
使其非必要:
使用required = False重新声明python文件中的字段。
因为一旦一个字段在python中声明required=True
,也会在数据库中设置为必需,但在xml的情况下则不一样。
希望它对您的情况有所帮助。
答案 1 :(得分:0)
In xml file you can do it:
<field name="customer_id" position="attribute">
<attribute name="required">False</attribute>
</field>
and in python code it is also possible to make required false.
If you want field required False in view add required=False in xml.
if you want field required False which is required True in parent (in database constrains) simply override it in inherited class.