向 Qweb 报告添加字段

Adding field to Qweb report

有字段 account.move.line.journal_id,我希望它显示在报告中。

我正在尝试

<tr t-foreach="p.account_move_line" t-as="p">
                <span t-esc="p.journal_id"/>
                </tr>

或类似这样的东西。

<tr t-foreach="p.account_invoice.payment_move_line_ids" t-as="p">
                <span t-esc="p.journal_id"/>

但出现错误

AttributeError: 'NoneType' object has no attribute 'account_move_line'

Error to render compiling AST
AttributeError: 'NoneType' object has no attribute 'account_move_line'
Template: account.report_invoice_document
Path: /templates/t/t/div/div[4]/div[2]/table/tr[2]/td[2]/tr
Node: <tr t-foreach="p.account_move_line" t-as="p">
                <span t-esc="p.journal_id"/>
                </tr>

在 t-foreach 中,您必须有要迭代的列表。我认为错误是您正在将值分配给 p,同时您正在迭代此变量。 尝试更改变量(考虑到 p 是您的 account_invoice 记录,否则您可以直接访问而无需 t-foreach):

<tr t-foreach="p.account_move_line" t-as="j">
    <span t-esc="j.journal_id"/>
</tr>

希望对您有所帮助 ;)