继承和修改 account.report_invoice_document table

Inherit and modify the account.report_invoice_document table

您好,我正在尝试创建一个继承报告模板 account.report_invoice_document 的 pdf 以替换 table。但是我有这个问题

AttributeError: 'NoneType' object has no attribute 'with_context' 
Error to render compiling AST AttributeError: 'NoneType' object has no attribute 'with_context' 
Template: 1045 Path: /templates/t/t/t[1] 
Node: <t t-set="o" t-value="o.with_context(lang=lang)"/>

不继承我也没问题

我的代码:

<template id="certificate_donation_template" inherit_id="account.report_invoice_document">
    <xpath expr="//table[@name='invoice_line_table']" position="replace">
        <table class="table table-condensed" name="invoice_line_table">
            <thead>
                <th class="text-center" style="width: 70%">Code</th>
                <th class="text-center" style="width: 15%">Date done</th>
                <th class="text-center" style="width: 15%">Amount</th>
                <th class="text-center" style="width: 15%">Payment Method</th>
            </thead>
            <tbody>
                <t t-as="doc" t-foreach="docs">
                    <tr>
                        <td>
                            <span t-esc="doc['donation_name']"/>
                        </td>
                        <td class="text-center">
                            <span t-esc="doc['donation_date_done']"/>
                        </td>
                        <td class="text-center">
                            <span t-esc="doc['donation_amount']"/>
                        </td>
                        <td class="text-center">
                            <span t-esc="doc['payment_method']"/>
                        </td>
                    </tr>
                </t>
            </tbody>
        </table>
    </xpath>
</template>

举报

    <report 
        attachment_use="True" 
        id="certificate_report" 
        menu="False"
        name="ngo_payment_certificate.certificate_donation_template" 
        paperformat="ngo_payment_certification_donation_certificate" 
        report_type="qweb-pdf" 
        string="Donations Certificate"
        model="ngo.donor"
        ></report>

__manifest__ 我有依赖帐户

问题出在 doc 上,您应该使用 o 调用打印输出中的字段

<tbody>
  <tr>
                        <td>
                            <span t-esc="o.donation_name"/>
                        </td>
                        <td class="text-center">
                            <span t-esc="o.donation_date_done"/>
                        </td>
                        <td class="text-center">
                            <span t-esc="o.donation_amount"/>
                        </td>
                        <td class="text-center">
                            <span t-esc="o.payment_method"/>
                        </td>
                    </tr>
                </t>

如果 donation_name 在 account.invoice 模型中。

只有属于同一型号的qweb模板才能继承