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

I have a field in my XML that is sometimes a URL, sometimes a phone number. I want to apply the widget="url" when the field contains a website but not when the field contains a phone number. I have a second field that tells the user whether the field contains a phone number of website.

<field name="openerp_val" widget="url" string ="openerp_val" attrs="{'invisible': [('field_diff','=','website')]}"/>
<field name="openerp_val" string ="openerp_val" attrs="{'invisible': [('field_diff','!=','website')]}"/>

I have tried the above and will only show the type of field in the bottom line of code. I think the second line is over writing the first line.

So how can i have a field displayed iwth a widget like url based on a condition?

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

Hi,

I think it will be better if you create two field (in py file openerp_val1 & openerp_val2 with same property then in xml like this )

<field name="openerp_val1" widget="url" string="openerp_val" attrs="{'invisible': [('field_diff','=','website')]}"/>

<field name="openerp_val2" string="openerp_val" attrs="{'invisible': [('field_diff','!=','website')]}"/>

then try it will work... I also tried with same field but its not taking two same field at a time it is only considering last one .

อวตาร
ละทิ้ง
ผู้เขียน

this answer would display the desired result, but it seems more like a work around rather than a solution. No way to conditionally display something as a URL?

Related Posts ตอบกลับ มุมมอง กิจกรรม
How to send url of a record by email ? แก้ไขแล้ว
2
มี.ค. 22
11351
What are the URL parameters available? แก้ไขแล้ว
4
ก.ค. 21
19588
1
มี.ค. 15
7054
db-filter by domain, not for subdomain แก้ไขแล้ว
5
ม.ค. 24
16132
Conditionally apply Domain on a field แก้ไขแล้ว
3
ต.ค. 21
28473