如何更改 xml 中的字段要求?

how to change a field requirement in xml?

我有一个字段 "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]

In ODOO if a field is set as required=True in python file the you can't marked it as required=Flase in xml file.

因为不需要:

用 required=False 重新声明 python 文件 中的字段。 因为一旦在 python 中声明了一个字段 required=True,它 也将在数据库 中设置为必需字段,但在 xml 的情况下则不同.

希望对您有所帮助。

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.