-1

我想在每张发票的合作伙伴分类帐报告中添加客户发票的状态(未结、已付款、草稿)。我正在尝试在 odoo 8 的合作伙伴分类帐报告中添加客户发票的状态。

这是我要继承的模板:

<template id="report_partnerledger">
<t t-call="report.html_container">
    <t t-call="report.internal_layout">
        <div class="page">
            <h2>Partner Ledger</h2>

            <div class="row">
                <div class="col-xs-3">
                    <strong>Chart of Accounts:</strong>
                    <p t-esc="get_account(data)"/>
                </div>
                <div class="col-xs-3">
                    <strong>Fiscal Year:</strong>
                    <p t-esc="get_fiscalyear(data)"/>
                </div>
                <div class="col-xs-3">
                    <strong>Journals:</strong>
                    <p t-esc="', '.join([ lt or '' for lt in get_journal(data) ])"/>
                </div>
                <div class="col-xs-3">
                    <strong>Partner's</strong>
                    <p t-esc="get_partners()"/>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-3">
                    <strong>Filter By:</strong>
                    <p>
                        <span t-if="data['form']['filter'] == 'filter_no'">Not filtered</span>
                        <span t-if="data['form']['filter'] == 'filter_period'">Filtered by period</span>
                        <span t-if="data['form']['filter'] == 'filter_date'">Filtered by date</span>
                        <p t-if="data['form']['filter'] == 'filter_period'">
                            Start Period: <span t-esc="get_start_period(data)"/>
                            End Period: <span t-esc="get_end_period(data)"/>
                        </p>
                        <p t-if="data['form']['filter'] == 'filter_date'">
                            Date from : <span t-esc="formatLang(get_start_date(data), date=True)"/><br />
                            Date to : <span t-esc="formatLang(get_end_date(data), date=True)"/>
                        </p>
                    </p>
                </div>
                <div class="col-xs-3">
                    <strong>Target Moves:</strong>
                    <p t-esc="get_target_move(data)"/>
                </div>
            </div>
            <table class="table table-condensed">
                <thead>
                    <tr>
                        <th>Date</th>
                        <th>JRNL</th>
                        <th>Ref</th>
                        <th>Account</th>
                        <th>Entry Label</th>
                        <th>Debit</th>
                        <th>Credit</th>
                        <th>Balance</th>
                        <th t-if="amount_currency">Currency</th>
                    </tr>
                </thead>
                <tbody>
                    <t t-foreach="docs" t-as="partner">
                    <tr>
                        <td colspan="5">
                                <strong t-esc="partner.ref"/>
                                - <strong t-esc="partner.name"/>
                        </td>
                        <td class="text-right">
                            <strong t-esc="sum_debit_partner(partner)"/>
                        </td>
                        <td class="text-right">
                            <strong t-esc="sum_credit_partner(partner)"/>
                        </td>
                        <td class="text-right">
                            <strong t-esc="formatLang((sum_debit_partner(partner) - sum_credit_partner(partner)), currency_obj=res_company.currency_id)"/>
                        </td>
                    </tr>
                    <tr t-if="initial_balance">
                        <td colspan="5">Initial Balance</td>
                        <td>
                            <span t-esc="formatLang(get_intial_balance(partner)[0][0])"/>
                        </td>
                        <td>
                            <span t-esc="formatLang(get_intial_balance(partner)[0][1])"/>
                        </td>
                        <td>
                            <span t-esc="formatLang(get_intial_balance(partner)[0][2], currency_obj=res_company.currency_id)"/>
                        </td>
                    </tr>
                    <tr t-foreach="lines(partner)" t-as="line">
                        <td>
                            <span t-esc="formatLang(line['date'], date=True)"/>
                        </td>
                        <td>
                            <span t-esc="line['code']"/>
                        </td>
                        <td>
                            <span t-esc="line['move_name']"/>
                        </td>
                        <td>
                            <span t-esc="line['a_code']"/>
                        </td>
                        <td>
                            <span t-esc="line['ref']"/>-<span t-esc="line['name']"/>
                        </td>
                        <td class="text-right">
                            <span t-esc="formatLang((line['debit']))"/>
                        </td>
                        <td class="text-right">
                            <span t-esc="formatLang((line['credit']))"/>
                        </td>
                        <td class="text-right">
                            <span t-esc="formatLang(line['progress'], currency_obj=res_company.currency_id)"/>
                        </td>
                        <td t-if="amount_currency">
                            <span t-esc="formatLang(line['amount_currency'])"/>
                        </td>
                    </tr>
                    </t>
                </tbody>
            </table>
        </div>
    </t>
</t>

为此,我添加了代码:

<template id="account_partner_ledger_other_custom" inherit_id="account.report_partnerledgerother">
    <xpath expr="//thead/tr" position="inside">
        <th>Status</th>
    </xpath>
</template>

通过这样做,我可以在合作伙伴分类帐报告中添加行状态,但我无法在合作伙伴分类帐报告中显示状态(已付款、未结或草稿)。我该怎么做?

4

1 回答 1

0

我使用以下方法做到了这一点:

self.cr.execute(
        "SELECT l.id, l.date, j.code, acc.code as a_code, acc.name as a_name, l.period_id, inv.state, inv.date_due, l.ref, m.name as move_name, l.name, l.debit, l.credit, l.amount_currency,l.currency_id, c.symbol AS currency_code " \
        "FROM account_move_line l " \
        "LEFT JOIN account_journal j " \
            "ON (l.journal_id = j.id) " \
        "LEFT JOIN account_account acc " \
            "ON (l.account_id = acc.id) " \
        "LEFT JOIN res_currency c ON (l.currency_id=c.id)" \
        "LEFT JOIN account_move m ON (m.id=l.move_id)" \
        "LEFT JOIN account_invoice inv ON (inv.move_id = l.move_id)" \
        "WHERE l.partner_id = %s " \
            "AND l.account_id IN %s AND " + self.query +" " \
            "AND m.state IN %s " \
            " " + RECONCILE_TAG + " "\
            "ORDER BY l.date",
            (partner.id, tuple(self.account_ids), tuple(move_state)))

    res = self.cr.dictfetchall()
    count = 0.0
    sum = 0.0
    if self.initial_balance:
        sum = self.init_bal_sum
    for r in res:
        sum += r['debit'] - r['credit']
        r['progress'] = sum
        full_account.append(r)
    return full_account

我加入了表格的数据,我从中获得了每张发票的状态。

于 2015-05-18T15:13:25.360 回答