跳至内容
菜单
此问题已终结
1 回复
5610 查看

looking at mrp_bom_strucuture_report:


<tr t-foreach="get_children(o.bom_line_ids)" t-as="l">
    <td style="padding-left: 20px;">
        <span style="color: white;" t-esc="'... '*(l['level'])"/>
        <span t-esc="l['pname']"/>
    </td>
    <td>
        <span t-esc="l['pqty']"/>
        <span t-esc="l['uname']" groups="product.group_uom"/>
    </td>
    <td>
        <span t-esc="l['code']"/>
...


How does this relate to a model? How do I add my fields I have added to mrp.bom.lines?


Cheers,

Rob

形象
丢弃
最佳答案

In Odoo Qweb template engine there are variables that you can use that are defined in the qweb context of the report render, for example as you could see there is a t-foreach tag to iterate over an 'docs' variable and name every element as 'o' docs in that report is an mrp.bom recordset so you could use the 'o' variable as you need by accessing it's fields, also you could review this particular interesting report parser at the end of the file 

/odoo/addons/mrp/report/mrp_bom_structure_report.py

where you could find the definition of the get_children function used in the report and more, specifically the method render_html is the one that is calling the report mrp_bom_strucuture_report to be rendered

形象
丢弃
相关帖文 回复 查看 活动
1
11月 24
20215
1
9月 23
3026
3
5月 23
5631
7
4月 23
49005
1
12月 22
7869