You are mixing multiple types of rendering odoo templates into something that can not work.
Your javascript <script>
tag is executed after the server renders the template so it can only set variables on the server side if you re render the orginal page. Usually that's done by creating a <form>
and passing data via <input>
to a controller. The controller then renders the template with the variable values from the inputs.
The error you are seeing TypeError: unhashable type: 'set'
is because:
- when doing
<t t-set="callUrl" t-value="sale_order.get_portal_url(suffix='/accept_order/' + {{ my_var }})" />
the string inside t-value is run as a python expression
- the python expression
{{ my_var }}
gives you the error TypeError: unhashable type: 'set'
To fix the error you could change setting the callUrl to:
<t t-set="callUrl" t-value="sale_order.get_portal_url(suffix='/accept_order/' + my_var )" />
Hint: the {{var}}
is only used inside t-attf-$name
To prevent the error following from my_var being potentially None (TypeError: must be str, not NoneType
) you could use python string formating:
<t t-set="callUrl" t-value="sale_order.get_portal_url(suffix='/accept_order/%s' % (my_var or '') )" />
As an alternative to posting a form, you can render templates in javascript if you do not need server side variables.