Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compose a link (`href`) in an Odoo 10 view

Tags:

odoo-10

I have a regular view in my views folder with the model= set etc. I am displaying fields with no issues. I just just need to compose a link and to complete this, all I need is the current record ID then hopefully I can do something as simple as this:

<a href="/rpt/the-report-for-widget?id={{ id }}">Report</a>

Unfortunately the views documentation only tells me how to use fields which is not compatible with what I need.

My understanding is that any regular view is a QWeb view thats really in a <template> tag, so according to this QWeb documentation I tried this:

<a href="/rpt/the-report-for-widget?id=t-esc="id"'>Report</a> and

<a t-attrf-href="/rpt/the-report-for-widget?id=#{id}'>Report</a> and

<a t-attrf-href="/rpt/the-report-for-widget?id=#{model.id}'>Report</a> and

<a t-attrf-href="/rpt/the-report-for-widget?id=#{record.id}'>Report</a>

and about a dozen other things and nothing seems to work.

(just so you don't ask, yes I am updating the module before checking the result in the view)

I would prefer not to use t-attf-href when I could simply use href. A pointer to specific documentation would be great.

like image 778
StartupGuy Avatar asked Dec 05 '25 10:12

StartupGuy


1 Answers

you can try this.

<a t-attrf-href="/rpt/the-report-for-widget?id={{id}}'>Report</a>
like image 90
Павел Храпун Avatar answered Dec 07 '25 17:12

Павел Храпун



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!