Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
4554 Vistas

Can any one tell me from where to get variable which is used in foreach? For example:-  t t-foreach="grouped_tasks" t-as="tasks"

In this example, "grouped_tasks" variable is used. From where I get this example?

Please help me!

Avatar
Descartar
Mejor respuesta

Reports can be developed 2 ways:

1) Directly print the report using current record (From Print button option in the form / tree view: Mostly without parser): Report is generated mostly we use "docs" variable to access the records to print the report.

2) From the wizard by passing some parameters to the parser (Custom Report): In the parser we can define the method and pass it to the qweb report by overriding render_html method..


Avatar
Descartar
Mejor respuesta

Hi,

t-foreach is iteration directive in qweb which take an expression returning the collection to iterate on, if you set of records in your model you can find data inside that record set using t-foreach please refer this link to understand more on t-foreach.

for example if have one2many_id in your model you can access that data inside one2many field using 

this statement t-foreach = one2many_id t-as = field

refer this link for example ​

Avatar
Descartar
Autor

Thanks!

Mejor respuesta

Take a Look at this example which is already in account module.

In XML file  here report engine calls py function declared in class. Github Link

In PY   Then the call redirect to py function. Github Link

 

Avatar
Descartar
Autor

Thanks for your help!