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

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

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Nis 23
8537
3
Eyl 20
4469
5
Haz 20
6813
2
Nis 20
6233
3
Tem 17
10648