تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
6080 أدوات العرض

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 


الصورة الرمزية
إهمال
أفضل إجابة

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!

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

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

الصورة الرمزية
إهمال

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

الكاتب

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?

أفضل إجابة

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
يوليو 16
4157
0
مارس 25
1552
4
أبريل 24
174434
0
ديسمبر 23
2309
5
يوليو 25
228707