Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
3930 Ansichten

Hello everybody!!!

I have a field named type_id which is a many2one to a table hr.contract.type. (where its fields are id, name, ...)

I want to make a field named Date_end invisible when the name of the contract is "CDI".

I tried like this : <field name="date_end" attrs="{'invisible':[('type_id.name,'=',"CDI")]}"/>

But it doesnt work.

Can anyone help please.

Thanks a lot in advance.

Best Regards.

Avatar
Verwerfen
Beste Antwort

Add the contract name as a related field in the contract object then change the domain in xml

<field name="date_end" attrs="{'invisible':[('my_related_field','=','CDI')]}"/>

NOTE : The code you posted has some errors it should be like this :

<field name="date_end" attrs="{'invisible':[('type_id.name','=','CDI')]}"/>

Let us now how it went for you !

Avatar
Verwerfen
Beste Antwort

Hello DressFar,


Try this :-

First Solution:-

<field name="date_end" attrs ="{'invisible': {'type_id': [('name', '=', 'CDI')]}}" / >


Second Solution :-

In py:-

type_id = fields.Many2one ("hr.contract.type", 'Type')

type_name = fields.Char(related='type_id.name', 'Type Name')

In Xml:-

<field name="type_id" attrs="{'invisible': [('type_name', '=', 'CDI')]}" />

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


Hope it works for you.

Thanks,

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
März 15
3724
2
Apr. 18
27795
0
Okt. 15
4114
1
Juli 25
522
1
Juni 25
1087