Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
4541 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang
Penulis

Thanks!

Jawaban Terbai

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
Buang
Penulis

Thanks for your help!