Унаследовать и изменить таблицу account.report_invoice_document - PullRequest
0 голосов
/ 10 марта 2020

Привет. Я пытаюсь создать PDF-файл, наследующий шаблон отчета account.report_invoice_document для замены таблицы. Но у меня есть эта проблема

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

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

На ___ манифесте __ у меня есть в аккаунте

Ответы [ 2 ]

1 голос
/ 31 марта 2020

Вы можете наследовать шаблон qweb только в том случае, если оба принадлежат одной и той же модели.

0 голосов
/ 11 марта 2020

Проблема здесь с do c, и вы должны использовать 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 присутствует в учетной записи Модель .invoice.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...