Community mailing list archives

community@mail.odoo.com

Re: variable is not reachable

by
Shivam Goyal
- 09/28/2015 11:53:50
k see the following example :

XML :-
<template  id = "my_template">
<p> Hello, <t t-esc = "name"/> </p> 
</template>

py file -: (rendering the above xml)

http.request.render("model.my_template",{"name":"World"}) 

Since we passes "name" as a key in the dictionary hence it is directly available as a variable in the template.
This example was taken for a website module. However if you are working on a report then you have to do the following

py file -:

def printing _report_method(cr,uid,ids,context=None)

data = {
   'partners':[
  
              {'name':'Partner1'},
               {'name':Partner2}]
                         ]

 }

return {
                        'type': 'ir.actions.report.xml',
                        'report_name': 'report.name',
                        'context':context,
                        'datas': {'model':'model.model','data':data}
                        }


XML :


<t t-foreach="data['partners']" t-as = "any_variable">
     <span><t t-esc = "any_variable['name']"</t></span>
<t>

I hope this helps

On Mon, Sep 28, 2015 at 9:08 PM, Khalid Saeed <khaled@centrivision.com> wrote:
@Mohamed Magdy

That would be considered as evaluating string 'partner' not the variable


@​Shivam Goyal
I am sorry I don't know how to pass the partner variable as you suggested.

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe