跳至内容
菜单
此问题已终结
3 回复
6078 查看

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
7月 16
4157
0
3月 25
1550
4
4月 24
174433
0
12月 23
2309
5
7月 25
228705