跳至內容
選單
此問題已被標幟
3 回覆
4548 瀏覽次數

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!

頭像
捨棄
最佳答案

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..


頭像
捨棄
最佳答案

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 ​

頭像
捨棄
作者

Thanks!

最佳答案

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

 

頭像
捨棄
作者

Thanks for your help!