Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
3287 Widoki

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.

Awatar
Odrzuć
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

Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
lis 23
1283
0
lis 21
2366
4
paź 21
80040
0
kwi 21
5459
1
gru 19
3745