İçereği Atla
Menü
Bu soru işaretlendi
4 Cevaplar
12261 Görünümler

Hi all,

how to use many2one field in xml attrs like this <field name="grade" attrs="{'invisible':[('many2onefield,'=',value]}"/>

Thanks is advance.

Avatar
Vazgeç
En İyi Yanıt

Hi Supreeth,

Ideally the attrs will be evaluated like [('integer','=','string')] so this will not work.

better create a related field  for the many2one and use the newly created field in the attrs

ex:

many2onefield_name = fields.Char(related="many2onefield.name", string="Name")

<field name="grade" attrs="{'invisible':[('many2onefield_name,'=',value]}"/>


Avatar
Vazgeç
En İyi Yanıt

I have perfect example atts for M2O field. can you see please below Answer


<field name="field_name" atts={'operation':domain}>

operation:

Like:

invisible

readonly

Domain:

[(field_name,'operator',Value)]


example:

<field name="name" attrs={'readonly':[('name','=','murugan')]}/>

Avatar
Vazgeç
En İyi Yanıt

Hello,


A new related field is the only way also for the latest version 14.0.

No need to set the Store=True, it won't store in the database and you could utilize it in the attrs invisible.


<field name="grade" attrs="{'invisible':[('new_related_field,'=',value]}"/>


Otherwise in demo data this is possible,    
    

<field name="department_id" model="hr.department" eval="obj().env.ref('hr.employee_admin').department_id.id"/>
Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Oca 25
29069
0
Ara 18
5607
6
Ara 22
15393
0
Şub 20
2918
2
Oca 20
7432