Skip to Content
Menu
This question has been flagged
3 Replies
4021 Views

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
Discard
Best Answer

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
Discard
Best Answer

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
Discard
Author

Thanks!

Best Answer

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
Discard
Author

Thanks for your help!