Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1032 Vizualizări

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
apr. 23
8537
3
sept. 20
4468
5
iun. 20
6812
2
apr. 20
6233
3
iul. 17
10647