Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
6081 Vistas

Hi 
I am trying to make a field autre_id invisible 

I tryed many methods to do that and i did not work

this my method:

(.py)

        'autre_id':fields.many2one('mon_module.autre', 'الحالة الإجتماعية', required=False),

(.xml)

     <field name="autre_id" attrs="{'invisible': [(' autre_id ', '=', 'False')]}"/>

  <field name="autre_id" invisible="1"/>

Can you help me to solve that

and thinks 


Avatar
Descartar
Mejor respuesta

Soumaya,

you can simply use :

 <field name="autre_id" invisible="1"/>

we use attrs in the case when we want to hide/readonly a filed on basis of some condition, for ex:

if you want to hide autre_id when your state is 'open',  you can use:

 <field name="autre_id" attrs="{'invisible': [('state', '=', 'open')]}"/>

Hope this help!

Avatar
Descartar
Autor Mejor respuesta

Thank you Pawan, but i tryed your solution and it does not work 

Avatar
Descartar

are you getting any error? can u provide your code..

Autor

no i don't hava any error, but this field still visble in my view

then check if you have defined that field again in your view.. after making it invisible.. or that view is inherited and that field is defined again.... or, is that view only loading?

Mejor respuesta

Hi,

In the XML code you provided, there is a spacing issue in the attrs attribute value for the invisible attribute. There is an extra space before and after the autre_id field name, which causes the attribute to not work as expected.

To fix the issue, you can remove the extra spaces in the attribute value as follows:

<field name="autre_id" attrs="{'invisible': [('autre_id', '=',False)]}"/>

That might be the Issue you are facing.

If u still having the Issue these are the ways you hide a field using XML

1. To hide a field using XML view, you can add the "invisible" attribute to the field and set it to "1". This will hide the field in the view. 

For example:

<field name="autre_id" attrs="{'invisible': [('autre_id', '=',False)]}"/>


2. Another Way, To hide a field using groups, first, you need to define a group by creating a record for it in the "res.groups" model. For example:

<record id="my_module.my_group" model="res.groups"> <field name="name">My Group</field> </record>

Then, you can add the group to the field's access rights using the "groups" attribute. For example:

<field name="my_field" groups="my_module.my_group"/>


Regards

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
jul 16
4157
0
mar 25
1552
4
abr 24
174434
0
dic 23
2310
5
jul 25
228708