Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
12635 มุมมอง

Hi all,

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

Thanks is advance.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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]}"/>


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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')]}/>

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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"/>
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ม.ค. 25
30385
0
ธ.ค. 18
5922
6
ธ.ค. 22
15895
0
ก.พ. 20
3253
2
ม.ค. 20
7823