Community: Framework mailing list archives

difficulties with t-field+arguments in website snippet

Pedro Cachaca
- 10/15/2014 10:01:44

How to manage "arguments" in a t-field, inserted in a website snippet ?

<t t-set="arg" t-value="1"/><div t-esc="res_company.bnb_ids[arg].description"/>
works fine in a snippet, because the editor will only save the html result


<t t-set="arg" t-value="1"/><div t-field="res_company.bnb_ids[arg].description"/>

doesn't work in a snippet, 
-> error "tuple indices must be integers, not NoneType" while evaluating

because the editor save

"<div t-field="res_company.bnb_ids[arg].description"/>"

instead of 

"<div t-field="res_company.bnb_ids[1].description"/>"

I really need to use arguments, because in many situation I do a t-foreach with arguments...
and I really would like to use snippets, because the content can be place in any page of the website.

I tried to solve this issue with javascript : the js rewrites the t-field (tag data-oe-expression)  but remains very complex because I use many models of t-fields in same snippets, and many snippets.

Thanks for your advise