Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
5375 Vistas

I have field

fields.Char('URL Common', invisible=True)

but it not working.

How i can fix it?

Avatar
Descartar

Make the field invisible through your XML. Either by not calling the field or by saying invisible="1".

Mejor respuesta

Hi,

Please tell me why do you need it from .py file? You can easily hide the field from XML view file in 3 ways:

1. Using attribute invisible="1", if you just need to hide.

Eg:

<field name="your_field" invisible="1" />;

2. Using attrs, if you need to hide based on a condition.

 Eg:

<field name="total_amount" attrs="{'invisible':[('currency_id','!=',company_id.currency_id)]}"/>;

3. Using security groups, if you want  to display field only to the  members a particular group.

Eg:

<field name="company_id" groups="your_group"/>;
Avatar
Descartar
Autor

Because i want to use python set value on invisible. Exp def _return_invisible(self): wh_hn = self.env.ref('fbv_core.warehouse_hn').pick_type_id.id wh_hcm = self.env.ref('fbv_core.warehouse_hcm').picking_type_id.id return ['|',('picking_type_id', '=', wh_hn), ('picking_type_id', '=', wh_hcm)] and on xml, i don't use get ref id

Then you don't need to call that field in view file, it will be hidden, no need to separately set an attribute in field definition. Or if you want to do something based on the value of inivisible and need to be hidden, then you can call the field with invisible="1" in view file.