Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
3286 Zobrazení

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
Zrušit
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

Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
lis 23
1283
0
lis 21
2366
4
říj 21
80040
0
dub 21
5459
1
pro 19
3745