2016-05-20 19 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

它的位置=「屬性」不是「屬性」,謝謝 –