Search code examples
odooqr-codeqweb

How to put url inside QR in odoo report


I want to create a QR that redirects to a url with the following code:

<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('QR', doc.id, 600, 50)" style="width:30px;height:30px;"/>

I want the value be like this: https://example.com/doc.id

I idea how to concat 2 strings? Thanks!!


Solution

  • You can just concat them right there:

    <img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('QR', my_url + str(doc.id), 600, 50)" style="width:30px;height:30px;"/>
    

    my_url + str(doc.id) could also be a lot of other things, but it's python code, because t-att-src will be evaluated later.

    Biggest concerns and things i can't answer right now:

    • how to handle an url within an url, look here
    • how will this escaped url work with Odoo's barcode generator
    • where to get the url from: can it be hardcoded or do you want to get it dynamically on conditions?