Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1045 Zobrazení

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
dub 23
8544
3
zář 20
4477
5
čvn 20
6815
2
dub 20
6244
3
čvc 17
10651