Michael M
Michael M

Reputation: 8763

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

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.

Upvotes: 3

Views: 5822

Answers (1)

you can try this.

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

Upvotes: 1

Related Questions