Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3228 Vistas

name="out_doc" attrs="{'invisible': ['|',('out_doc', '=', False),('for_country','=','us')]}">
editable="bottom">
name="lab_test"/>
name="name" optional="hide"/>
name="stop_check" optional="hide"/>
name="product_id"/>
name="att_file" widget="binary" attrs="{'invisible': [('att_file', '!=', False)]}"
options="{'accepted_file_extensions': '.jpeg,.pdf,.jpg,.png'}" filename="name"
string="Attachment"/>
name="att_file" widget="binary" attrs="{'invisible': [('att_file', '=', False)]}"
options="{'accepted_file_extensions': '.jpeg,.pdf,.jpg,.png'}" filename="name"
string="Attachment"/>






this is my code in this code the attribute invisible is working on for_country but didn't do invisible the field when i don't record in it.

Avatar
Descartar
Autor

<field name="out_doc" attrs="{'invisible': ['|',('out_doc', '=', False),('for_country','=','us')]}">
<tree editable="bottom">
<field name="lab_test"/>
<field name="name" optional="hide"/>
<field name="stop_check" optional="hide"/>
<field name="product_id"/>
<field name="att_file" widget="binary" attrs="{'invisible': [('att_file', '!=', False)]}"
options="{'accepted_file_extensions': '.jpeg,.pdf,.jpg,.png'}" filename="name"
string="Attachment"/>
<field name="att_file" widget="binary" attrs="{'invisible': [('att_file', '=', False)]}"
options="{'accepted_file_extensions': '.jpeg,.pdf,.jpg,.png'}" filename="name"
string="Attachment"/>
<button name="open_file_preview" attrs="{'invisible': [('att_file', '=', False)]}" string="Preview File" type="object" class="oe_inline"/>
</tree>
</field>

Autor

this is complete code

Mejor respuesta

Hi Mohsan Raza,


To address the situation where you want to make a One2many field invisible if it contains no data, you can follow these steps:


1. Add a Boolean (True/False) field to the model. This field will serve as an indicator of whether the One2many field has data or not.


2. Write a compute method for the Boolean field. In this method, you can check if the One2many field contains any records. If it does, set the Boolean field to True; otherwise, set it to False.


3. In the XML view definition, apply the `attrs` attribute to the One2many field. Use this attribute to conditionally make the One2many field invisible based on the value of the Boolean field.


This approach allows you to dynamically control the visibility of the One2many field based on the presence of data.

Hope it will be helpful to you.

Thanks & Regards,
Email:    odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
nov 23
1219
0
nov 21
2308
4
oct 21
79961
0
abr 21
5410
1
dic 19
3680