简体   繁体   English

Odoo,请以XML看到字段,但以灰色显示

[英]Odoo, see fields in XML but in grey

I want kow if it's possible to see the field with this value but I want this field can't be change or can't be included a value. 我希望知道是否可以看到具有此值的字段,但我希望此字段不能更改或不能包含值。

For example I want to display my product id of my application, the product_id is unique. 例如,我想显示我的应用程序的产品ID,product_id是唯一的。 I want to see my product_id but the field must be not change (grey). 我想查看我的product_id,但该字段不得更改(灰色)。

my .py
    _columns = {  
# Product
        'clicshopping_products_id': fields.integer('Product Id', size=5, help="Id product table of ClicShopping must be unique"),
    }

and my xml
<field name="clicshopping_products_id"/>

Do you have an idea. 你有想法吗。

Thank you. 谢谢。

Add the readonly attribute . 添加readonly属性 You can do this either in your model or in the view (one of those in enough). 您可以在模型或视图(足够多的其中之一)中执行此操作。 Example of the latter: 后者的示例:

<field name="clicshopping_products_id" readonly="1"/>

This won't change the fields color to gray, but it will made it uneditable, and that's what you ultimately want, if I understand your post correctly. 这不会将字段的颜色更改为灰色,但会使其变为不可编辑状态,如果我正确理解了您的信息,这就是您最终想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM