Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
4015 Näkymät

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
Hylkää
Paras vastaus

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
Hylkää
Paras vastaus

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
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
0
maalisk. 15
3772
2
huhtik. 18
27927
0
lokak. 15
4190
2
elok. 25
2392
1
heinäk. 25
894