2016-05-20 17 views
1

我有一个字段“required”= True,并且我想要以继承形式更改为False。如何更改xml中的字段要求?

 <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

检查CUSTOMER_ID的蟒蛇文件,如果它按照要求=真那么<属性名=“需要”>被标记假不行 – prakash

+0

它设置为真 –

回答

1

在ODOO如果一个字段在Python文件中设置为需要= True时,你 不能将其标记为需要=产品嫁接在XML文件。

为了使它非必需:在Python文件与所需=假

重新申报领域。 ,因为一旦一个字段在Python中声明required=True也被设置为数据库中所要求的,但是在xml的情况下也是如此。

希望它可以帮助你的情况。

+0

是。到底。那是我做的。我重新宣布该领域的蟒蛇。谢谢 –

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. 
+0

它的位置=“属性”不是“属性”,谢谢 –