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

Hello

I have a field called "link" in my custom module, it contains a valid url.


I need to use this link as smartbutton.. basically this works (design tbd)

(button class="oe_stat_button ps-2" name="link_url" type="object"  icon="fa-globe" string="Link" attrs="{'invisible':[('link','=',False)]}")
(field name="link" widget="url" /)
(/button)


Now I want to manipulate the SmartButton-String depending on the URL.

Something like this here (in pseudo-code cause it doesnt work for me)


(button class="oe_stat_button ps-2" name="link_url" type="object"  icon="fa-globe" string="Link" attrs="{'invisible':[('link','=',False)]}")
(field name="link" invisible="1" /)
(t t-set="linkname" t-value="'Link to ABC'" t-if="'ABC' in link" /)
(t t-set="linkname" t-value="'Link to XYZ'" t-elif="'XYZ' in link" /)
(t t-set="linkname" t-value="'Link to Something'" t-else="" /)
(div class="o_field_widget o_stat_info")
(span class="o_stat_value")(field name="link" widget="url" /)(/span)
(span class="o_stat_text") (t t-out="linkname" /)(/span)
(/div)
(/button)

-> 

Caused by: TypeError: Cannot use 'in' operator to search for 'ABC' in undefined


Does anyone have a solution to do this in the XML?

Yes i know i could add a link_name computed in the python but I would prefer the xml-way.


best regards


Update: changed code to ( instead of

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
t-att-href url get error แก้ไขแล้ว
2
เม.ย. 23
8540
3
ก.ย. 20
4470
Inherit from inherited view แก้ไขแล้ว
5
มิ.ย. 20
6813
2
เม.ย. 20
6237
3
ก.ค. 17
10650