Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define link text different in Odoo widget=url

Tags:

odoo

I have made read only computed URL-field based on invoice number. It works nicely but I would like to produce text part only itself like 400:

<a href="https://external_site_invoice?num=400">400</a>

Now it's producing whole link as text which is quite ugly

<a href="https://external_site_invoice?num=400">https://external_site_invoice?num=400</a>

My Odoo fields are defined this way...

ext_invoice_number= fields.Integer(string="Ext number")

def _showlink(self):
    for rec in self:
        if rec.ext_invoice_number:
            if  rec.ext_invoice_number>0:
                rec.ext_link="https://external site/invoice?num=%d" % (rec.ext_invoice_number,)


ext_link = fields.Char(string="Link",compute=_showlink,)

How can I define text part of URL in Odoo to be different than link? This is poorly documented or it's not possible?

like image 501
Eino Mäkitalo Avatar asked Mar 14 '23 08:03

Eino Mäkitalo


1 Answers

you can define the text attribute in widget definition like that:

<field name="field_with_url" widget="url" readonly="1" text="My own text"/>

Regards

like image 126
Diego Richi Avatar answered Apr 02 '23 07:04

Diego Richi