<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_journal">
    <t t-call="report.html_container">
        <t t-foreach="docs" t-as="o">
            <t t-call="report.internal_layout">
                <div class="page">
                    <h2>Journal</h2>

                    <div class="row mt32">
                        <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>Journal:</strong>
                            <p t-field="o.journal_id.name"/>
                        </div>
                        <div class="col-xs-3">
                            <strong>Period:</strong>
                            <p t-field="o.period_id.name"/>
                        </div>
                    </div>
                    <div class="row mb32">
                        <div class="col-xs-3">
                            <strong>Entries Sorted By:</strong>
                            <p t-if="data['form'].get('sort_selection') == 'l.date'">Date</p>
                            <p t-if="data['form'].get('sort_selection') == 'am.name'">Journal Entry Number</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>Move</th>
                                <th>Date</th>
                                <th>Account</th>
                                <th>Partner</th>
                                <th>Label</th>
                                <th>Debit</th>
                                <th>Credit</th>
                                <th t-if="display_currency(data)">Currency</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr t-foreach="lines(o.period_id.id, o.journal_id.id)" t-as="line">
                                <td><t t-esc="line.move_id.name &lt;&gt; '/' and line.move_id.name or ('*'+str(line.move_id.id))"/></td>
                                <td><t t-esc="formatLang(line.date,date=True)"/></td> 
                                <td><span t-field="line.account_id.code"/></td>
                                <td><t t-esc="line.partner_id and line.partner_id.name[:23]"/></td>
                                <td><t t-esc="line.name[:35]"/></td>
                                <td><t t-esc="formatLang(line.debit, currency_obj=res_company.currency_id)"/></td>
                                <td><t t-esc="formatLang(line.credit, currency_obj=res_company.currency_id)"/></td>
                                <td t-if="display_currency(data)">
                                    <span t-esc="formatLang(line.amount_currency, currency_obj=line.currency_id) if line.amount_currency else ''"/>
                                </td>
                            </tr>
                        </tbody>
                    </table>

                    <div class="row">
                        <div class="col-xs-4 pull-right">
                            <table class="table table-condensed">
                                <tr>
                                    <td><strong>Total</strong></td>
                                    <td><strong t-esc="formatLang(sum_debit(o.period_id.id, o.journal_id.id), currency_obj=res_company.currency_id)"/></td>
                                    <td><strong t-esc="formatLang(sum_credit(o.period_id.id, o.journal_id.id), currency_obj=res_company.currency_id)"/></td>
                                </tr>
                            </table>
                        </div>
                    </div>

                </div>
            </t>
        </t>
    </t>
</template>
</data>
</openerp>
